Redocly / Redocly/redoc

Previous doc anchors still referenced after redoc component has been rebuild

Open
#2,567 0 comments 0 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

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

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 problem by calling Redoc.destroy(), then Redoc.init() with a different OpenAPI spec in the redoc-container element. Start at the destroy and initialization entry points, then inspect the tag-menu anchor behavior after switching documents; done means clicking a tag produces the correct URL anchor without refreshing the page.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi, typescript
Domain
documentation, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.