Skip to content

Build your personal knowledge base with Trilium Notes

refactor(react/global_menu): get rid of outsideChildren

Elian Doranf0ac301417b6
diff --git a/apps/client/src/widgets/buttons/global_menu.tsx b/apps/client/src/widgets/buttons/global_menu.tsx
index 5b3cfe862f..b6e8507261 100644
--- a/apps/client/src/widgets/buttons/global_menu.tsx
+++ b/apps/client/src/widgets/buttons/global_menu.tsx
@@ -99,7 +99,7 @@ function SwitchToOptions() {
}
}
-function MenuItem({ icon, text, title, command, disabled, active, outsideChildren }: MenuItemProps<KeyboardActionNames | CommandNames | (() => void)>) {
+function MenuItem({ icon, text, title, command, disabled, active }: MenuItemProps<KeyboardActionNames | CommandNames | (() => void)>) {
return <FormListItem
icon={icon}
title={title}
@@ -107,7 +107,6 @@ function MenuItem({ icon, text, title, command, disabled, active, outsideChildre
onClick={typeof command === "function" ? command : undefined}
disabled={disabled}
active={active}
- outsideChildren={outsideChildren}
>{text}</FormListItem>
}
@@ -115,8 +114,7 @@ function KeyboardActionMenuItem({ text, command, ...props }: MenuItemProps<Keybo
return <MenuItem
{...props}
command={command}
- text={text}
- outsideChildren={<KeyboardShortcut actionName={command as KeyboardActionNames} />}
+ text={<>{text} <KeyboardShortcut actionName={command as KeyboardActionNames} /></>}
/>
}
@@ -177,7 +175,9 @@ function ZoomControls({ parentComponent }: { parentComponent?: Component | null
<FormListItem
icon="bx bx-empty"
className="zoom-container"
- outsideChildren={<>
+ >
+ {t("global_menu.zoom")}
+ <>
<div className="zoom-buttons">
<ZoomControlButton command="toggleFullscreen" title={t("global_menu.toggle_fullscreen")} icon="bx bx-expand-alt" />
&nbsp;
@@ -185,8 +185,8 @@ function ZoomControls({ parentComponent }: { parentComponent?: Component | null
<ZoomControlButton command="zoomReset" title={t("global_menu.reset_zoom_level")}>{zoomLevel}{t("units.percentage")}</ZoomControlButton>
<ZoomControlButton command="zoomIn" title={t("global_menu.zoom_in")} icon="bx bx-plus" />
</div>
- </>}
- >{t("global_menu.zoom")}</FormListItem>
+ </>
+ </FormListItem>
) : (
<MenuItem icon="bx bx-expand-alt" command="toggleFullscreen" text={t("global_menu.toggle_fullscreen")} />
);
diff --git a/apps/client/src/widgets/react/FormList.tsx b/apps/client/src/widgets/react/FormList.tsx
index 8991dea002..eca9450619 100644
--- a/apps/client/src/widgets/react/FormList.tsx
+++ b/apps/client/src/widgets/react/FormList.tsx
@@ -89,7 +89,6 @@ interface FormListItemOpts {
description?: string;
className?: string;
rtl?: boolean;
- outsideChildren?: ComponentChildren;
}
const TOOLTIP_CONFIG: Partial<Tooltip.Options> = {
@@ -97,7 +96,7 @@ const TOOLTIP_CONFIG: Partial<Tooltip.Options> = {
fallbackPlacements: [ "right" ]
}
-export function FormListItem({ className, icon, value, title, active, disabled, checked, onClick, selected, rtl, triggerCommand, outsideChildren, description, ...contentProps }: FormListItemOpts) {
+export function FormListItem({ className, icon, value, title, active, disabled, checked, onClick, selected, rtl, triggerCommand, description, ...contentProps }: FormListItemOpts) {
const itemRef = useRef<HTMLLIElement>(null);
if (checked) {
@@ -124,7 +123,6 @@ export function FormListItem({ className, icon, value, title, active, disabled,
) : (
<FormListContent description={description} {...contentProps} />
)}
- {outsideChildren}
</li>
);
}