question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v1.0.0-beta : ScrollSpy not working properly when clicking on an <i>-element.

See original GitHub issue

Expected Behavior

Click on Button scrolls Section below into view.

Current Behavior

I have a button [a.btn-large] witch should scoll to a section below in the document.

<a href="#contact" class="waves-effect waves-light btn-large"><i class="material-icons left">message</i>[link-text]</a>
[snip]
<section id="contact" class="contact fixed-bg scrollspy">[content]</section>

if i click on the icon instead of the link-text it just jumps, without scrolling, to the ancor.

Possible Solution

Line#6150 in Materialize,js: You’re comparing the $trigger to 'a[href="#' + scrollspy.$el.attr('id') + '"]' to start scrolling.

But if the $trigger is an <i> inside the <a> nothing happens.

Your Environment

Chrome 65.0.3325.181 JQuery 3.1.1 Materialize 1.0.0-beta

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
Spikeworldcommented, Jul 18, 2018

Experienced the same issue today. For a quick workaround I added style="pointer-events:none;" to <i>

2reactions
sanisoclemcommented, Mar 25, 2019

same thing happens when the link has an svg. I did some digging and it seems like its because of this:

https://github.com/Dogfalo/materialize/blob/e5f686b87bd95eeec2b9c7cac8e0eb7241f0ccaf/js/scrollspy.js#L108

normally $target would be the anchor but for some reason, it is set to the svg or i element (could be others). The following css fixes the issue for me:

a > svg,
a > i {
  pointer-events: none;
}

also found this great article that demonstrates this problem: https://css-tricks.com/links-inline-svg-staying-target-events/

Read more comments on GitHub >

github_iconTop Results From Across the Web

bootstrap 4 beta scrollspy not working - Stack Overflow
I'm using the javascript file from this scrolling nav template to scroll down to a section when you click a link. This works,...
Read more >
node_modules/bootstrap-vue/CHANGELOG.md - GitLab
activeElement if no return focus element provided (#3033) (e5c0aa5) ... v-b-scrollspy: support when vue-router is in hash based route mode (closes #2722) ...
Read more >
Scrollspy - Bootstrap
Automatically update Bootstrap navigation or list group components based on scroll position to indicate which link is currently active in the viewport.
Read more >
Popovers · JCU Web Framework
Zero-length title and content values will never show a popover. Specify container: 'body' to avoid rendering problems in more complex components (like our...
Read more >
aurelia/Discuss - Gitter
Can you show the element? MisanthropeGirl. @MisanthropeGirl. Dec 06 2016 15:21 UTC. No function, just mailto:${json.email}. Andrew Stoker. @AStoker.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found