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

Scrollspy missaligns when loading page with anchor #1536

Closed
SergejGleithmann opened this issue Mar 30, 2023 · 1 comment · Fixed by #1831
Closed

Scrollspy missaligns when loading page with anchor #1536

SergejGleithmann opened this issue Mar 30, 2023 · 1 comment · Fixed by #1831
Assignees
Milestone

Comments

@SergejGleithmann
Copy link

SergejGleithmann commented Mar 30, 2023

Description of the bug
The Scrollspy breaks when loading a page with an anchor. Since using an anchor as for example by clicking on the scrollspy on an already loaded page does not reload the page and therefore does not produce the bug this behavior is uncommon to detect I guess.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Scrollspy page with an anchor in URL (e.g. https://tailwind-elements.com/docs/standard/navigation/scrollspy/#example-3).
  2. Scrolling inside the Scrollspy related element shows the anchor position is now wrongly considered to be the top of the page (e.g. section 1 is highlighted instead of section 3 when landing on the page and if scrolling to the top nothing is highlighted instead of section 1).

Expected behavior
Loading the page with an anchor should not affect the Scrollspy offset.

Actual behavior
Loading the page with an anchor creates an offset for the Scrollspy

@smolenski-mikolaj smolenski-mikolaj added this to the v1.0.0-beta3 milestone Mar 31, 2023
@juujisai juujisai assigned iprzybysz and unassigned Trochonovitz Jun 30, 2023
@iprzybysz iprzybysz moved this from Pending to Todo in Tailwind Elements Jul 17, 2023
@iprzybysz iprzybysz moved this from Todo to Pending in Tailwind Elements Jul 19, 2023
@juujisai juujisai assigned juujisai and unassigned iprzybysz Jul 26, 2023
@juujisai juujisai linked a pull request Jul 27, 2023 that will close this issue
@github-project-automation github-project-automation bot moved this from Pending to Done in Tailwind Elements Jul 27, 2023
@SergejGleithmann
Copy link
Author

SergejGleithmann commented Aug 29, 2023

Landing on the page with an anchor is now fixed. However reloading the page after having scolled the bar still creates the offset. You can replicate this by going to the scrollspy scroll to the bottom within the window with the scrollspy and then reload the page. The scroll state will keep the same (e.g. remain at the bottom) but the scrollspy will reset to top position.

Does one create a new issue for this or could we reopen this one if this is an issue worth investigating? (I am new to this.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants