Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scrollspy): Spying on nested navs fails to activate for .nav-link's inside nav-item's #23967

Merged
merged 6 commits into from
Sep 17, 2017
Merged

Conversation

tmorehouse
Copy link
Contributor

@tmorehouse tmorehouse commented Sep 16, 2017

When spying on nested navs, if using the markup where .nav-link is inside a .nav-item,
the parent previous sibling was not being highlighted. This PR addresses that issue with two additional lines of code (not including tests):

<nav id="navbar-example3" class="navbar navbar-light bg-light">
  <a class="navbar-brand" href="#">Navbar</a></li>
  <ul class="nav nav-pills flex-column">
    <li class="nav-link"><a class="nav-link" href="#item-1">Item 1</a></li>
    <ul class="nav nav-pills flex-column">
      <li class="nav-item"><a class="nav-link ml-3 my-1" href="#item-1-1">Item 1-1</a></li>
      <li class="nav-item"><a class="nav-link ml-3 my-1" href="#item-1-2">Item 1-2</a></li>
    </ul>
    <li class="nav-item"><a class="nav-link" href="#item-2">Item2</a></li>
    <li class="nav-item"><a class="nav-link" href="#item-3">Item3</a></li>
    <ul class="nav nav-pills flex-column">
      <li class="nav-item"><a class="nav-link ml-3 my-1" href="#item-3-1">Item 3-1</a></li>
      <li class="nav-item"><a class="nav-link ml-3 my-1" href="#item-3-2">Item 3-2</a></li>
    </ul>
  </ul>
</nav>

I discovered this issue when I was finishing porting over ScrollSpy into Boostrap-Vue (via PR bootstrap-vue/bootstrap-vue#1068), and figured I would create a PR on v4-dev to fix the official version as well.

@Johann-S
Copy link
Member

thanks @tmorehouse but can you add a unit test please ?

@tmorehouse
Copy link
Contributor Author

I'll see what I can do... (I'll have to familiarize myself with Bootstrap's test facilities)

@Johann-S
Copy link
Member

if you need some help do not hesitate here or on Slack 😉

@tmorehouse
Copy link
Contributor Author

tmorehouse commented Sep 16, 2017

@Johann-S unit test has been updated, and passes (after I fixed my typos - also called troy-o's 😉 )

@tmorehouse tmorehouse changed the title fix(scrollspy): Spying on nested navs didn't work for .nav-link's inside nav-item's fix(scrollspy): Spying on nested navs fails to activate for .nav-link's inside nav-item's Sep 17, 2017
@Johann-S Johann-S merged commit 6c70c70 into twbs:v4-dev Sep 17, 2017
@mdo mdo mentioned this pull request Sep 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants