mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 08:49:51 +02:00
fix(v2): better UX for docsVersionDropdown on mobile when there's a single version, fixes #4932 (#4986)
This commit is contained in:
parent
aa176274be
commit
4a6de5cf7a
1 changed files with 7 additions and 6 deletions
|
@ -68,14 +68,15 @@ export default function DocsVersionDropdownNavbarItem({
|
|||
return items;
|
||||
}
|
||||
|
||||
const items = getItems();
|
||||
|
||||
const dropdownVersion =
|
||||
activeDocContext.activeVersion ?? preferredVersion ?? latestVersion;
|
||||
|
||||
// Mobile is handled a bit differently
|
||||
const dropdownLabel = mobile ? 'Versions' : dropdownVersion.label;
|
||||
const dropdownTo = mobile
|
||||
? undefined
|
||||
: getVersionMainDoc(dropdownVersion).path;
|
||||
// Mobile dropdown is handled a bit differently
|
||||
const dropdownLabel = mobile && items ? 'Versions' : dropdownVersion.label;
|
||||
const dropdownTo =
|
||||
mobile && items ? undefined : getVersionMainDoc(dropdownVersion).path;
|
||||
|
||||
return (
|
||||
<DefaultNavbarItem
|
||||
|
@ -83,7 +84,7 @@ export default function DocsVersionDropdownNavbarItem({
|
|||
mobile={mobile}
|
||||
label={dropdownLabel}
|
||||
to={dropdownTo}
|
||||
items={getItems()}
|
||||
items={items}
|
||||
isActive={dropdownActiveClassDisabled ? () => false : undefined}
|
||||
/>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue