scalar / scalar

Scalar is an open-source platform with:                                       🌐 Modern Rest API Client                                        📖 Beautiful API References                                        ✨ 1st-Class OpenAPI/Swagger Support
https://scalar.com
MIT License
6.41k stars 203 forks source link

Inconsistent scroll position on page load when navigating to a specific endpoint #3447

Open brandonabajelo-zoom opened 3 days ago

brandonabajelo-zoom commented 3 days ago

What happens?

First of all, massive congrats to everyone for this scalar project. It really is top notch in a lot of ways compared to other similar tools out there. It has been a joy to use and I'm excited to see how far this package goes.

For context, I have been using the react wrapper in a next 13 app: "@scalar/api-reference-react": "^0.3.106"

      <ApiReferenceReact
        configuration={{
          spec: { content: spec },
          withDefaultFonts: false,
          hideModels: true,
          tagsSorter: 'alpha',
          searchHotKey: 'k',
          hideDarkModeToggle: true,
          hideDownloadButton: true,
          hiddenClients: specType === 'events' ? true : [],
          defaultHttpClient: {
            targetKey: 'shell',
            clientKey: 'curl',
          },
          operationsSorter: 'alpha'
        }}
      />

One issue I'm seeing pretty consistently is when I attempt to navigate to a specific api endpoint url (not just the root of the page), scalar attempts to scroll to the correct position, but it doesn't always consistently take me to the endpoint I'm looking for. Sometimes it does, sometimes it doesn't, sometimes the scroll stops on a section that needs "Show more". The problem still persists even with { defaultOpenAllTags: true }, so that leads to me believe the issue may either be with my css, or within the package itself. Potentially the calculation of page height is effecting something? Overflow-x issue?

I do have a fixed header on top of the scalar component, where I'm setting --scalar-custom-header-height to account for the height of my custom header. Perhaps this is messing up some calculation?

root.style.setProperty('--scalar-custom-header-height', ${headerHeight}px);

I imagine others have run into this before and I'm curious if there are any tips or recommendations for how to resolve! Please let me know if I can share more details.

Much appreciated!

What did you expect to happen?

Regardless of whats tags are open or not, i expect all URLs to scroll to their appropriate position.

OpenAPI Document

No response

amritk commented 3 days ago

Oh I believe we may have just fixed this! Try the latest version

brandonabajelo-zoom commented 3 days ago

hey @amritk still seeing the same thing after the version bump, though it does appear improved.

amritk commented 3 days ago

Sure thing can take a look

amritk commented 2 days ago

Okay I was testing in our react example and it seems to be working, any chance you can setup a minimal reproduction?