#2282·redoc

Scrolling keeps rewriting url after a Redoc element was removed

Author: benjaminWeskerCreated Mar 15, 2023Updated Sep 23, 2026
LabelsType: Bug

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" }