Skip to content
This repository was archived by the owner on Jul 25, 2022. It is now read-only.

Subsections in nested elements are not recognized #102

Open
justlevine opened this issue Sep 22, 2019 · 2 comments
Open

Subsections in nested elements are not recognized #102

justlevine opened this issue Sep 22, 2019 · 2 comments
Assignees
Labels

Comments

@justlevine
Copy link

justlevine commented Sep 22, 2019

For some reason, only subsections in the same parent element are recognised by scrollnav. This is obviously not ideal behavior, as there are various reasons one might be nesting their subsections in a different element (e.g. lists).

Config:

scrollnav.init( content, {
	sections: 'h2',
	subSections: 'h3',
	insertLocation: 'prepend',
} );

Html

<section>
    <h2>Section Title</h2> <!--Will appear-->
    <ul>
        <li>
            <h3>Step 1</h3> <!-- Will NOT appear -->
            <p>Content goes here</p>
        </li>
    <ul>
</section>

Suggestions on how to fix?

@jimmynotjim
Copy link
Owner

I use a nextUntil function to search for the subsections that only looks at elems on the same level. I did this to try and speed up the dom query but I'll have to rethink it. Thanks for opening the bug.

@jimmynotjim jimmynotjim self-assigned this Oct 4, 2019
@jimmynotjim jimmynotjim added the bug label Oct 4, 2019
@makrohard
Copy link

makrohard commented Jan 24, 2021

I did come across the same issue. I "solved" this behaviour, repeating the headings on the expected level and hide the duplicates using visibility:hidden (display:none shows heading in nav, but does not scroll to correct position). Works for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants