docsify icon indicating copy to clipboard operation
docsify copied to clipboard

Auto scroll doesn't work for h6 headings.

Open shannon opened this issue 2 months ago • 2 comments

Description

I discovered this because some of the links that show up in the search plugin do not auto scroll to the correct location.

It seems that for quite some time, the onNavigate query selector only goes down to h5.

Surely this line should be :where(h1, h2, h3, h4, h5, h6) no?

Expected behavior

When clicking on a link that includes an anchor that is an h6 header ###### Header, the page should navigate to the correct page and then auto scroll to the correct header.

Actual behavior

The page navigates to the correct page but it does not scroll at all. It doesn't scroll to the anchor or to the top of the page like it should. It ends up in a location based on the scrollTop position of the page navigated way from, which can be quite disorienting.

Steps to reproduce

  1. Create a document test.md with a large amount of content to make sure that there is enough to create scrolling
  2. At the bottom of the document add ###### Test
  3. In _sidebar.md add - [Test](test.md#test)
  4. Load the page and click the Test in the sidebar
  5. Observe that test.md is loaded but does not auto scroll to the Test section.

Environment

  • Docsify Version: 5.0.0-rc
  • Browser Version: all

Additional Information

  • [x] Bug still occurs when all/other plugins are disabled?

shannon avatar Nov 14 '25 18:11 shannon

I'm not sure why I omitted the h6 tag earlier, but I think adding it should be fine.

sy-records avatar Nov 15 '25 02:11 sy-records

@sy-records thanks for taking the time to respond.

Yea I figured it was probably just an honest mistake but I questioned why no one else had hit this issue in all this time. So I thought maybe I was doing something wrong.

I suspect not many people link directly to an h6. As mentioned, I discovered it only because the search results were not behaving correctly. I have a bunch of documents that are generated from the typedoc markdown plugin and sometimes it will include an h6.

It's a simple enough PR to make but I couldn't find any tests related to the auto scroll. If you could point me to them (presuming there are any) I can submit a PR.

shannon avatar Nov 15 '25 12:11 shannon

Hey i want to contribute to fix this issue

satyansh2004 avatar Dec 13 '25 02:12 satyansh2004

Welcome to submit PR

sy-records avatar Dec 13 '25 13:12 sy-records