swagger-api / swagger-api/swagger-ui

Zenscroll Addition Causes Performance Issues, Undesired Behavior

Open
#5,978 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: support
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:

  1. Import Swagger UI to a default React application.
  2. Create a list of anchor tags.
  3. Select your anchor tag.
  4. 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

image

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.