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

Always scroll to clicked sidebar content #522

Open
jhildenbiddle opened this issue Jun 7, 2018 · 8 comments
Open

Always scroll to clicked sidebar content #522

jhildenbiddle opened this issue Jun 7, 2018 · 8 comments
Labels
bug confirmed as a bug

Comments

@jhildenbiddle
Copy link
Member

Docsify does not scroll to the clicked sidebar link content if the link was the last sidebar link clicked.

  1. Visit the Markdown section on the docsify-themeable site
  2. Click any section link (Ex: Code)
  3. Scroll the page
  4. Click the same section link

I believe the expectation is that docsify would scroll back to the section clicked.

Perhaps removing the hash from the URL, then updating it with the section hash would provide a quick fix?

@SidVal
Copy link
Member

SidVal commented Jun 7, 2018

I think you are talking about this 🐛 #422, aren't you?

@jhildenbiddle
Copy link
Member Author

The two issues are closely related, but the descriptions of how to proceed are different.

I believe the fix for this issue is straightforward: when a user clicks a link in the sidebar, always scroll that content into view at the top of the viewport--even if it's the active link / URL. If a user clicks a sidebar link, then waits for the content to scroll into view, then scrolls 10 pixels, clicking the same sidebar link should scroll the content back 10px to the initial scroll position. That's it.

For #422, I agree that the sidebar should always reflect the current scroll position of the page: as the user scrolls, the active link in the sidebar should be highlighted in all scenarios. I do not , however, think the URL should be updated as the page is scrolled. Instead, the URL should be updated only when a user-initiated navigation action has occurred (i.e. clicking a sidebar link).

@qmarcos
Copy link

qmarcos commented Sep 12, 2018

+1 to this.

I can manual fix it creating links with full parameters in href value.

For example, if my first heading in a sample.md page is "01. Introduction", I could achieve page change and reset scroll position with this link:

[My Link](/sample.md?id=_01-introduction)

But it could be perfect that changing section always reset scroll position to the top, is natural behaviour when changing the main content.

A colateral issue with this approach appears when I attempt to replicate this behaviour on sidebar.md links, I get wrong subnavigation rendering (subnavigation is attached under main navigation item that is not the selected one).

@timaschew timaschew added the bug confirmed as a bug label Jan 29, 2019
@timaschew timaschew added this to the 4.x milestone Jan 29, 2019
@anikethsaha
Copy link
Member

I think this has been fixed in develop.

@jhildenbiddle jhildenbiddle removed this from the 4.x milestone Jun 14, 2020
@macrozone
Copy link

is there an update on this?

@pkieltyka
Copy link

hi, also checking if this has been fixed? seems like a bug that really hurts the UX .. is there a common/easy solution?

@sifex
Copy link

sifex commented Sep 24, 2021

Hey all, I believe this is the configuration parameter that is required to be changed from the default:
https://docsify.js.org/#/configuration?id=auto2top

@beth-panx
Copy link

beth-panx commented Feb 17, 2022

Still seeing this bug. Even with config of auto2top=true set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug confirmed as a bug
Projects
None yet
Development

No branches or pull requests

9 participants