diff options
| author | Troy Morehouse <[email protected]> | 2017-09-17 04:30:37 -0300 |
|---|---|---|
| committer | Johann-S <[email protected]> | 2017-09-17 09:30:37 +0200 |
| commit | 6c70c70f637267ca109f44ff63f564892ece42bf (patch) | |
| tree | 796ce351f08f25ce111022bbab65136a820d7770 /js/src | |
| parent | e296c1374104ef949ca8f6307f13b09dd4c4b09c (diff) | |
| download | bootstrap-6c70c70f637267ca109f44ff63f564892ece42bf.tar.xz bootstrap-6c70c70f637267ca109f44ff63f564892ece42bf.zip | |
fix(scrollspy): Spying on nested navs fails to activate for .nav-link's inside nav-item's (#23967)
* fix(scrollspy): Handle nested navs when nav-link inside nav-item
* [scrolspy] Find only child .nav-link's inside .nav-item
* [scrollspyt] Add tests for nested navs with nav-link inside nav-item
* fix troy-o's in test
Diffstat (limited to 'js/src')
| -rw-r--r-- | js/src/scrollspy.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 70067c0b3..e8f0d3101 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -54,6 +54,7 @@ const ScrollSpy = (() => { ACTIVE : '.active', NAV_LIST_GROUP : '.nav, .list-group', NAV_LINKS : '.nav-link', + NAV_ITEMS : '.nav-item', LIST_ITEMS : '.list-group-item', DROPDOWN : '.dropdown', DROPDOWN_ITEMS : '.dropdown-item', @@ -264,6 +265,8 @@ const ScrollSpy = (() => { // Set triggered links parents as active // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor $link.parents(Selector.NAV_LIST_GROUP).prev(`${Selector.NAV_LINKS}, ${Selector.LIST_ITEMS}`).addClass(ClassName.ACTIVE) + // Handle special case when .nav-link is inside .nav-item + $link.parents(Selector.NAV_LIST_GROUP).prev(Selector.NAV_ITEMS).children(Selector.NAV_LINKS).addClass(ClassName.ACTIVE) } $(this._scrollElement).trigger(Event.ACTIVATE, { |
