Redocly / Redocly/redoc

Scrolling keeps rewriting url after a Redoc element was removed

Open
#2,282 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug
Dominant language
TypeScript
Stars
25.9k
Forks
2.4k
Avg merge
13h 10m
Merged PRs (30d)
4

Description

Describe the bug
When we add a redoc element to the page with Redoc.init() then we remove the element from the page (typically by changing page in a SPA), the scrolling listeners are not removed: everytime we scroll, the hash part of the url will be rewritten.

Expected behavior
I expect this behaviour to disappear when the redoc element is removed, or to have a Redoc.destroy() function to remove it by hand.

Minimal reproducible OpenAPI snippet(if possible)
Using Thomas Lulé stackblitz to reproduced the bug here: https://stackblitz.com/edit/web-platform-bqyjhd?file=script.js

Try to click the "change page" button then scroll in the empty space to see the url changes.

The only difference with thats that exemple is that i am using Redoc in node_modules (v2.0.0) :

here my redoc in package-lock :
"redoc": {
"version": "2.0.0",
"requires": {
"@redocly/openapi-core": "^1.0.0-beta.104",
"classnames": "^2.3.1",
"decko": "^1.2.0",
"dompurify": "^2.2.8",
"eventemitter3": "^4.0.7",
"json-pointer": "^0.6.2",
"lunr": "^2.3.9",
"mark.js": "^8.11.1",
"marked": "^4.0.15",
"mobx-react": "^7.2.0",
"openapi-sampler": "^1.3.0",
"path-browserify": "^1.0.1",
"perfect-scrollbar": "^1.5.5",
"polished": "^4.1.3",
"prismjs": "^1.27.0",
"prop-types": "^15.7.2",
"react-tabs": "^3.2.2",
"slugify": "~1.4.7",
"stickyfill": "^1.1.1",
"style-loader": "^3.3.1",
"swagger2openapi": "^7.0.6",
"url-template": "^2.0.8"
}

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

Start with the linked StackBlitz reproduction in script.js and trace the Redoc.init() lifecycle when the element is removed. Check where scrolling listeners are registered and whether removal or an explicit cleanup path is handled; done means scrolling after the element is removed no longer rewrites the URL hash.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
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.