mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +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;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const items = getItems();
|
||||||
|
|
||||||
const dropdownVersion =
|
const dropdownVersion =
|
||||||
activeDocContext.activeVersion ?? preferredVersion ?? latestVersion;
|
activeDocContext.activeVersion ?? preferredVersion ?? latestVersion;
|
||||||
|
|
||||||
// Mobile is handled a bit differently
|
// Mobile dropdown is handled a bit differently
|
||||||
const dropdownLabel = mobile ? 'Versions' : dropdownVersion.label;
|
const dropdownLabel = mobile && items ? 'Versions' : dropdownVersion.label;
|
||||||
const dropdownTo = mobile
|
const dropdownTo =
|
||||||
? undefined
|
mobile && items ? undefined : getVersionMainDoc(dropdownVersion).path;
|
||||||
: getVersionMainDoc(dropdownVersion).path;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DefaultNavbarItem
|
<DefaultNavbarItem
|
||||||
|
@ -83,7 +84,7 @@ export default function DocsVersionDropdownNavbarItem({
|
||||||
mobile={mobile}
|
mobile={mobile}
|
||||||
label={dropdownLabel}
|
label={dropdownLabel}
|
||||||
to={dropdownTo}
|
to={dropdownTo}
|
||||||
items={getItems()}
|
items={items}
|
||||||
isActive={dropdownActiveClassDisabled ? () => false : undefined}
|
isActive={dropdownActiveClassDisabled ? () => false : undefined}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue