storybook: [Bug]: URL with Hash ('#') in Storybook Do Not Scroll to Correct Position (ID Name)

Describe the bug

URLs with hashes (‘#’) and fragment IDs that lead to elements with id attributes do not scroll to the correct position when opening a fresh Storybook page from such URLs.

To Reproduce

  • Go to a Storybook page of sufficient height, get the URL of an anchor.
  • Create a new tab, paste the URL, and enter it into the search bar.
  • Notice that the linked ID is not in view and that the viewport is too high on the page.

System

Storybook Environment Info:

  System:
    OS: macOS 14.2.1
    CPU: (12) arm64 Apple M2 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm <----- active
  Browsers:
    Chrome: 120.0.6099.234
    Safari: 17.2.1
  npmPackages:
    @storybook/addon-actions: 7.5.3 => 7.5.3 
    @storybook/addon-docs: 7.5.3 => 7.5.3 
    @storybook/addon-essentials: 7.5.3 => 7.5.3 
    @storybook/addon-interactions: 7.5.3 => 7.5.3 
    @storybook/addon-links: 7.5.3 => 7.5.3 
    @storybook/addons: 7.5.3 => 7.5.3 
    @storybook/blocks: 7.5.3 => 7.5.3 
    @storybook/builder-vite: 7.5.3 => 7.5.3 
    @storybook/react: 7.5.3 => 7.5.3 
    @storybook/react-vite: 7.5.3 => 7.5.3 
    eslint-plugin-storybook: 0.6.15 => 0.6.15 
    storybook: 7.5.3 => 7.5.3 

Additional context

Nuances:

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 22 (2 by maintainers)

Most upvoted comments

I confirm. I have the same problem on version 8.3.3 of the storybook.

Having the same error on v7

The documentation website portion of this has been fixed!

I updated the labels once more to reflect that.

Having the same problem on Storybook v7…