Skip to content

Commit

Permalink
fix(language-menu): always render inter-locale links (#11013)
Browse files Browse the repository at this point in the history
* feat(dropdown): add alwaysRenderChildren option

* fix(language-menu): always render links to other locales
  • Loading branch information
caugner authored Apr 26, 2024
1 parent c9fc3de commit e74ffd5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions client/src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ main {
width: 1px !important;
}

.contents {
display: contents;
}

.hidden {
display: none;
}
Expand Down
9 changes: 8 additions & 1 deletion client/src/ui/molecules/dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ export function DropdownMenuWrapper({

export function DropdownMenu({
children,
alwaysRenderChildren = false,
onClose = () => {},
}: {
children: React.ReactNode;
alwaysRenderChildren?: boolean;
onClose?: (event?: Event) => void;
}) {
const { isOpen, wrapperRef, close, disableAutoClose } =
Expand All @@ -82,7 +84,12 @@ export function DropdownMenu({
onClose(event);
}
});
if (!isOpen) return null;

if (alwaysRenderChildren) {
return <div className={isOpen ? "contents" : "hidden"}>{children}</div>;
} else if (!isOpen) {
return null;
}

return <>{children}</>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function LanguageMenu({
{native}
</Button>

<DropdownMenu>
<DropdownMenu alwaysRenderChildren>
<Submenu menuEntry={menuEntry} />
</DropdownMenu>
</DropdownMenuWrapper>
Expand Down

0 comments on commit e74ffd5

Please sign in to comment.