-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
[v2] Sidebar menu also set active the Navbar menu #3067
Comments
Hi, If all the docs of your sidebar 1 have https://v2.docusaurus.io/docs/theme-classic/#navbar Nevertheless, I think we should support this by default without requiring you to activate with explicit path/regex option on purpose. Will try to understand what happened, because whil reading the code I feel like this auto activation of navbar link was explicitly disable for some reason. |
Hey @slorber Not sure if it is the desired behaviour. Maybe it is a small bug? |
Yep, totally agree. This is my navbar: links: [
{
to: "docs/foundations-and-experiences/ux-principles",
label: "Foundations",
position: "left",
activeBasePath: "docs/foundations-and-experiences",
},
{
to: "docs/language-and-design/colors",
label: "Design",
position: "left",
activeBaseRegex: "docs/(language-and-design|designer)",
},
{
to: "docs/components/status",
label: "Components",
position: "left",
activeBasePath: "docs/components",
},
{
label: "Web Dev",
position: "right",
activeBaseRegex: "docs/web-dev/(guides|api|support|fed-team)",
items: [
{
label: "Docs",
to: "docs/web-dev/guides/creating-a-new-app",
activeBasePath: "docs/web-dev/guides",
},
{
label: "Support",
to: "docs/web-dev/support/help",
activeBaseRegex: "docs/web-dev/(support|fed-team)",
},
{
label: "Storybook",
to: "/storybook",
activeBasePath: "storybook",
},
{
label: "API",
to: "docs/web-dev/api/contributing-new-features",
activeBasePath: "docs/web-dev/api",
},
],
},
{
to: "docs/mobile-dev/mobile-dev-intro",
label: "Mobile Dev",
position: "right",
activeBasePath: "docs/mobile-dev",
},
], All the active links work for the exception of the Web-dev that is a Dropdown menu 🤔 But it still doesn't active the navbar item, only the sub-items The |
I'm sorry but I'm unable to understand what you want. Can you display screenshots, link to code or something? Here you can see 2 items can get highlighted: Docs and 2.0-alpha.54. You'd want something else to be highlighted? For me, when you say "the dropdown menu", this is the whole ul with all the versions, it is not supposed to "activate", what do you expect from activating this menu Can you draw something in https://excalidraw.com/ so that I understand exactly what UI you want? |
Sorry for not being clear The code I sent before is for this menu. In my case, the menu is {
label: "Web Dev",
position: "right",
activeBaseRegex: "docs/web-dev/(guides|api|support|fed-team)",
items: [
{
label: "Docs",
to: "docs/web-dev/guides/creating-a-new-app",
activeBasePath: "docs/web-dev/guides",
},
} |
Will have to check tomorrow but maybe it requires a to attribute on the
parent item
Le mar. 21 juil. 2020 à 18:02, Paulo Andrade <[email protected]> a
écrit :
… Sorry for not being clear
When I am saying dropdown menu, I mean the main item/title and not the
internal list
[image: image]
<https://user-images.githubusercontent.com/1236101/88077700-c6ac2900-cb38-11ea-886e-f2119f3e1852.png>
The code I sent before is for this menu.
I can see the menu items inside of the dropdown being active but not the
dropdown itself
Also, looking in the HTML generated, the div with the dropdown title as no
active class
In my case, the menu is Web Dev -> Docs. Docs is highlighted, but not Web
Dev
{
label: "Web Dev",
position: "right",
activeBaseRegex: "docs/web-dev/(guides|api|support|fed-team)",
items: [
{
label: "Docs",
to: "docs/web-dev/guides/creating-a-new-app",
activeBasePath: "docs/web-dev/guides",
},
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3067 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFW6PRR37EPFG437I7PCPLR4W3ZDANCNFSM4O23RWLQ>
.
|
@prma85 according to what I see in the code, Can't you add a "to" attribute? |
@slorber yes, it did the trick |
great yes this is probably not very convenient but at least there's a workaround. Does "#" has any unintended side-effect? |
I didn't notice any side-effect. Looks all good :) |
Great. Tell me if alpha 59 gives you any trouble |
Hey @slorber, I just updated it to alpha 59 and not it generates errors on build 🤔 (works with yarn start tho) TypeError: sidebar.map is not a function (undefined) TypeError: sidebar.map is not a function
at DocSidebar (main:125515:4742)
at d (main:128597:498)
at $a (main:128600:16)
at a.b.render (main:128605:476)
at a.b.read (main:128605:18)
at Object.renderToString (main:128615:364)
at serverEntry_render (main:202384:375) And this is my sidebar.js (works fine on alpha 58) |
Hi, This is surprising, unfortunately I'm not able to reproduce. I need more infos, if you can give me access to your site's code (or create a small repro) that helps. Also I need to see the full content of the sidebar file (+ all the versioned sidebar files if available). You can try to debug this with dichotomy: remove versions, remove docs, remove sidebar content, until your site work |
🤔 I got my sidebars.js as simpler as possible module.exports = {
docs: [
{
type: "category",
label: "Design",
items: [
"language-and-design/colors",
"language-and-design/typography",
"language-and-design/spacing",
"language-and-design/empty-states",
"language-and-design/data-entry",
"language-and-design/visibility-security-and-permissions",
],
}
]
}; But I am still getting the error Repo: https://github.com/prma85/iQ.design.system.docs |
I only change was updating from alpha 58 to alpha 59 |
@prma85 in such case you shuld avoid using semver ranges in your package.json so that azure stick to existing versions? This is very strange to have your CI not respecting lockfile, why is that? About your problem, I don't have access to this repo that is private, if you send me an invite I'll look at this |
It is on propose not using the lock file. I have some custom packages from a mono repo used there (like storybook) and the idea is on each deploys it will always get the latest version of the packages. Publishing a new version of the package will trigger a deploy for the docs website I send the invite But I got the issue solved. 🎉 In my website, I am using a custom DocPage to add styling to the edit button and add an extra button for feedback (which will create an issue in the repository) And looks like you guys changed the implementation for it, so, my swizzle wasn't valid anymore. I got the same issue before when updating to alpha 58, but at that time, the build was complaining about the docpage, but now, it was complaining about the sidebar. Doing a new swizzle for the DocPage and adding my custom code (an useEffect to execute an external function) solved the issue. Now the issue is with links. It is complaining about broken links. For example,
The link is correct since I have the However, another link in the same file is resolved without issue Any ideas? |
Thanks, I see Sorry to have to change some implementation details of that component, unfortunately, it's required to fix some issues in the docs plugin. It is likely to happen again on next versions because there are other things I'd like to fix regarding the docs plugin and the exposed theme api surface which is currently a bit blurry and likely to cause such breaking changes. About the links, this is probably already fixed (leading / appended by mistake) and going to be released soon, but please give me the markdown of that link to double-check |
@slorber Thanks On v1 I was just adding a custom script and then, when loading the page, it was looking for the edit link and doing the necessary work for adding the extra button. This doesn't work on v2 because the page is loaded and not the content for the first time. There are some milliseconds there with waiting for a render. The alternative was using I checked the links and looks all good. Example:
and the MD file has the following content: ## NPM Registry
| int / rc / prod |
| ---------------------- |
| [iQmetrix registry] |
[iqmetrix registry]: (https://dev.azure.com/iqmetrix/Hub/_packaging?_a=feed&feed=iqmetrix) |
Sorry but I don't understand what you try to do. If this is not related to this issue at all, I'd rather discuss about this in another issue where you give me all the details, screenshots of v1 vs v2 etc...
All links with a protocol are not checked (it is a bug that adds a weird / at the beginning and let us think it's an absolute internal link, but it will be fixed very soon) |
🚀 Feature
When creating a multi-level docs page with different menus, normally we go with
sidebar.js
And for my nav bar, I would go with
docusaurus.config.js
However, there is no link between the navbar and when opening a Navbar, I will get only the menus for that navbar item, and due to this, the navbar link doesn't keep active when switching the sidebar items.
Motivation
Be able to create multi-level/layers docs site and keep the navbar menu active
Pitch
Normally when creating a docs page, and it is too big or too complex (for example, a design system docs or API docs), we need to divide it by sections. As today, if we divide the docs, we don't have a clear indication of what is the active section.
Maybe, the Navbar API could be extended to add an optional property to link the sidebar object to be active
For example:
So, when navigating on any items of the
components_menu
array, it will keep the navbar itemComponents
activeThe text was updated successfully, but these errors were encountered: