Skip to content

Commit

Permalink
fix: dropdown icon when no option is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
vandreleal committed Jul 3, 2023
1 parent eea44d3 commit b2d0472
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/theme/NavbarItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ function CustomNavbarItem(props) {

const { isLoggedIn } = useAuthContext()

// Add platform label with icon
const sdks =
items &&
useMemo(
() => items.map(sdk => ({ ...sdk, label: PlatformLabel(sdk) })),
[items]
)

const selectedSDK = useMemo(() => {
if (label === "SDK" && items.length) {
return items.find(item =>
Expand All @@ -38,12 +46,6 @@ function CustomNavbarItem(props) {
}
}, [items, label, pathname])

if (selectedSDK) {
return (
<PlatformNavbarItem {...itemProps} label={PlatformLabel(selectedSDK)} />
)
}

if (
type === "docsVersionDropdown" &&
pathname
Expand Down Expand Up @@ -79,18 +81,11 @@ function CustomNavbarItem(props) {
<OriginalNavbarItem
{...itemProps}
docId={activeVersion && activeVersion.mainDocId}
items={sdks}
/>
)
}

const PlatformNavbarItem = ({ items, ...props }) => {
const sdks = useMemo(
() => items.map(sdk => ({ ...sdk, label: PlatformLabel(sdk) })),
[items]
)
return <OriginalNavbarItem {...props} items={sdks} />
}

const PlatformLabel = ({ id, label }) => (
<span className="navbar__link__sdk">
{id && (
Expand Down

0 comments on commit b2d0472

Please sign in to comment.