swagger-api / swagger-api/swagger-ui
Zenscroll Addition Causes Performance Issues, Undesired Behavior
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A (please complete the following information)
- OS:
- Browser: Chrome
- Version: 81
- Method of installation: npm
- Swagger-UI version: 3.25.1
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Include the Swagger UI element on any SPA with href="#" elements.
Describe the bug you're encountering
When you import and initialize Swagger UI on your page, one of the libraries it includes by default is zenscroll. This dependency itself runs with the expectation it should be used with all anchors across the webpage, and so will automatically cause scrolling to/from anchor elements across your website, not just restricted to Swagger UI. When working with other components that intend to handle anchors themselves, this then causes conflicts - most recently with a component that uses its own anchors with just a href="#" tag, as that causes it to unconditionally scroll to the top of the page whenever clicked.
Using another solution to handle scrolling when selecting methods so that we can remove zenscroll, or figuring out a way to conditionally enable/disable it (vs. diving into their documentation) would be a huge help to letting Swagger UI be relatively isolated to its own content.
To reproduce...
Steps to reproduce the behavior:
- Import Swagger UI to a default React application.
- Create a list of anchor tags.
- Select your anchor tag.
- Notice that zenscroll is applying its listener to each of the tags.
Expected behavior
The Swagger UI elements will scroll appropriately when selecting elements, but will not apply to other elements.
Screenshots

Additional context or thoughts
Sorry if there is something unclear about this issue. Let me know what additional guidance I can provide!
Fwiw, if you run into this issue of automatic scrolling across your page when using Swagger UI, try adding "window.NoZensmooth = true" in your app. This will disable the behavior.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue by importing and initializing Swagger UI in a default React application, then add unrelated anchor tags using href="#". Start by tracing how the bundled zenscroll listener is applied; done means Swagger UI still scrolls its own elements without affecting anchors elsewhere on the page.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100