Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Previous doc anchors still referenced after redoc component has been rebuild #2567

Open
emouty opened this issue Jul 31, 2024 · 0 comments
Open

Comments

@emouty
Copy link

emouty commented Jul 31, 2024

Describe the bug

I use Redoc inside an static website with a menu to that allow to switch between docs

<!DOCTYPE html>
<html lang="en">
<link rel="stylesheet" href="/index.css">
<head>
    <script src="/provided/redoc.standalone.js" defer></script>
    <script src="/script.js" defer></script>
</head>
<body>
<div class="hamburger-menu">
    <input id="menu__toggle" type="checkbox">
    <label class="menu__btn" for="menu__toggle">
        <span></span>
    </label>
    <div id="sidebar" class="menu__box"></div>
</div>
<div class="redoc" id="redoc-container"></div>
</body>

When switching doc I call

Redoc.destroy();
// then later
Redoc.init(newOpenApiSpec,
                 {
                   expandResponses: "200,201",
                   sortPropsAlphabetically: true,
                   sortTagsAlphabetically: true,
                   hideSingleRequestSampleTab: true,
                   sideNavStyle: "path-only",
                 },
                 document.getElementById("redoc-container"));

But once the new OpenAPI spec is loaded, clicking on an item of from the tag menu generate the wrong anchor on the url. The only solution is to refresh the page to fix it. It seems that something is not cleaned during call to Redoc.destroy().

Expected behavior

Clicking on an item of from the tag menu generate the right anchor on the url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant