Skip to content

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

Open
@emouty

Description

@emouty

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions