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

DocCardList element renders the wrong items #10475

Open
6 of 7 tasks
rossgalloway opened this issue Sep 3, 2024 · 1 comment
Open
6 of 7 tasks

DocCardList element renders the wrong items #10475

rossgalloway opened this issue Sep 3, 2024 · 1 comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@rossgalloway
Copy link

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

I have run into a bug where the DocCardList element renders the wrong items when linking to an category index with a DocCardList element.

Using the tutorial example from https://docusaurus.new/codesandbox, I create a new sidebar:

const sidebars = {
  tutorialSidebar: [
    "intro",
    {
      type: "category",
      label: "Tutorial - basics",
      items: [
        "tutorial-basics/create-a-page",
        "tutorial-basics/create-a-document",
        "tutorial-basics/create-a-page",
        {
          type: "link",
          label: "Manage Docs Versions →",
          href: "/docs/tutorial-extras/",
        },
      ],
    },
    {
      type: "category",
      label: "Tutorial-Extras",
      link: {
        type: "doc",
        id: "tutorial-extras/index",
      },
      items: [
        "tutorial-extras/manage-docs-versions",
        "tutorial-extras/translate-your-site",
      ],
    },
  ],
};

New index page for tutorials-extras looks like this (backticks changed to single-quotes so formatting works here):

# Tutorial Extras

'''mdx-code-block
import DocCardList from '@theme/DocCardList';

<DocCardList />
'''

Note the new index page for tutorial-extras and the new link element in the tutorial-basics section sending you to the tutorial-extras/index page.

When clicking on the link to tutorial-extras the navigation sends you to the correct index page but the DocCardList is populated by elements from the tutorial-basics category and not the tutorial-extras category. This happens even when clicking directly on the Tutorial - Extras sidebar element.

There is a separate, related issue where the link element in the sidebar is prioritized in terms of focus, but I'll make a new issue for that.

Reproducible demo

https://codesandbox.io/p/devbox/brave-allen-d39ddg?workspaceId=971447fd-9df5-4a54-a72d-33087efcd2fa

Steps to reproduce

  1. click on tutorial section
  2. click on tutorials - extras in sidebar. See that the populated list of elements is incorrect
    or
  3. click on tutorials - basics in the sidebar, then click on Tutorial Extras → sub-item. See that the populated list of elements is incorrect.

Expected behavior

Cards should populate from the category where the doc element exists and not from the link element.

Actual behavior

Cards populate from the link element. Or maybe just from the first instance where the link occurs?

Your environment

occurs in sandbox and also in my local environment.

  • Public source code:
  • Public site URL:
  • Docusaurus version used: 3.5.2
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): I am using Firefox 129.0.2 and node v21.7.0
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): Windows 11 Home 23H2 with WSL2 - Ubuntu 20.04.6 LTS

Self-service

  • I'd be willing to fix this bug myself.
@rossgalloway rossgalloway added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Sep 3, 2024
@OzakIOne
Copy link
Collaborator

OzakIOne commented Sep 3, 2024

I guess it's related to #9923 (reply in thread)

@OzakIOne OzakIOne removed the status: needs triage This issue has not been triaged by maintainers label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

No branches or pull requests

2 participants