Skip to content

Hash plugin sets scrollRestoration (but never resets it) #841

@jarred-cz

Description

@jarred-cz

Describe the bug

The hash plugin sets scrollRestoration to "manual" when opening Fancybox, which causes the page always jumps to the top of the page after F5 (reload) - because browser does not remember the scroll position.

It should re-set it to "auto" on onClose event IMHO.

Reproduction

  1. Place the gallery outside the first viewport.
  2. Scroll down to the gallery.
  3. Refresh the page—the browser will leave you at this position.
  4. Open Fancybox.
  5. Close Fancybox.
  6. Reload the page—the browser will scroll to the top.

Additional context

This setting remains active even after hard reloading the page — scrollRestoration is not reset, it remains at the current history entry. The browser will not natively restore the scroll when reloading because "manual" prevents it from doing so. Default scrollRestoration value is only restored after opening the page in a new tab/window.

So just opening Fancybox will "destroy" the browser's behavior for all other pages visited in the same browser window.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue has not been triaged by maintainers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions