Docusaurus打开左侧导航栏菜单中的子菜单时出现错误。

huangapple go评论53阅读模式
英文:

Docusaurus bug when opening submenus in the left nav-bar menu

问题

我们已经使用 Docusaurus 很长一段时间了,但最近我们从我们的文档网站收到反馈,有些菜单没有正确展开。

我们的结构如下所示:

菜单 1
|
|
|-- 子菜单 1
|      |
|      - 子菜单 1.1
|           |
|           - 链接 1.1.1
|           |
|           - 链接 1.1.2
|           |
|           - 链接 1.1.3
|
|-- 子菜单 2
       |
       - 子菜单 2.1
            |
            - 链接 2.1.1
            |
            - 链接 2.1.2
            |
            - 链接 2.1.3

例如,当有人尝试打开子菜单 2.1 时,它不会展开,但如果我尝试键入适当的链接来访问链接 2.1.1,它是可以访问的。如果我在页面加载时手动键入链接 2.1.1 的链接(例如),它会正常显示展开的子菜单 2.1。

错误的 Docusaurus 网站

我们尝试在不同计算机之间使用相同的 Chrome 版本,似乎对于此 bug,我们得到不同的响应。

似乎我们的 JS 中存在一些创建导航栏类的 bug。有人以前遇到过这个 bug 并知道如何解决吗?

我尝试过的事项:

  • 强制在 CSS 文件中添加 height: auto !important,以便包含导航栏的容器可以自动调整其高度。

    • 回答:菜单打开并显示了下面的所有链接选项,但它不会再次折叠回去。
  • 尝试找到哪个脚本在创建和处理这些类。

    • 回答:我找不到它。
英文:

We are using docusaurus for a long time, but lately we are receiving feedbacks from our Docs website that some menus are not properly opening.

we have a structure like this example

Menu 1
|
|
|-- Submenu 1
|      |
|      - Submenu 1.1
|           |
|           - Link 1.1.1
|           |
|           - Link 1.1.2
|           |
|           - Link 1.1.3
|
|-- Submenu 2
       |
       - Submenu 2.1
            |
            - Link 2.1.1
            |
            - Link 2.1.2
            |
            - Link 2.1.3

When someone tries to open submenu 2.1, for example, it does not expand, but if I try to reach the link 2.1.1 typing the appropriate link, it is reachable. If I hardtype the link for this link 2.1.1 (for example) when the page loads, it shows the submenu 2.1 expanded normally.

Error docusaurus website

We tried with the same chrome versions between different computers, and it seems that we are getting different responses for this bug.

it seems that we have some bug on the JS that is creating the classes for this nav-bars. Has anyone experienced this bug before and know how to solve this issue?

What I tried:

  • hardcode the css file with height: auto !important so the container that contains the nav-bar could adjust automatically its height.

    • R- The menu opened and showed all link options below it, but it was not collapsing back again.
  • Tried to find which script was creating and addressing the classes.

    • R- I couldn`t find it

答案1

得分: 1

这是一个与prefers-reduced-motion嵌套可折叠问题相关的Docusaurus错误,详情请查看:https://github.com/facebook/docusaurus/issues/8932

好消息是,Docusaurus版本2.4.1已经修复了这个问题:
https://github.com/facebook/docusaurus/releases/tag/v2.4.1
https://twitter.com/docusaurus/status/1658106844970188804

只需打开你的package.json文件,升级版本,重新构建应用程序,问题就会得到解决。

"dependencies": {
"@docusaurus/core": "^2.4.1",
"@docusaurus/plugin-client-redirects": "^2.4.1",
"@docusaurus/preset-classic": "^2.4.1",
"@docusaurus/theme-live-codeblock": "^2.4.1",

英文:

This was a docusaurus bug related to prefers-reduced-motion nested collapsible bug, see this: https://github.com/facebook/docusaurus/issues/8932

Good news is that docusaurus version 2.4.1 fixed that:
https://github.com/facebook/docusaurus/releases/tag/v2.4.1
https://twitter.com/docusaurus/status/1658106844970188804

Just go to your package.json file, upgrade the versions, build the app again, and you should be fine.

  "dependencies": {
     "@docusaurus/core": "^2.4.1",
     "@docusaurus/plugin-client-redirects": "^2.4.1",
     "@docusaurus/preset-classic": "^2.4.1",
     "@docusaurus/theme-live-codeblock": "^2.4.1",

huangapple
  • 本文由 发表于 2023年4月11日 01:08:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75979115.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定