chore(global_menu): dismiss menu when entering fullscreen

This commit is contained in:
Elian Doran 2025-09-22 20:06:01 +03:00
parent 311f4aded8
commit 1c9f1ba82c
No known key found for this signature in database

View File

@ -155,7 +155,7 @@ function ZoomControls({ parentComponent }: { parentComponent?: Component | null
useEffect(updateZoomState, []); useEffect(updateZoomState, []);
function ZoomControlButton({ command, title, icon, children }: { command: KeyboardActionNames, title: string, icon?: string, children?: ComponentChildren }) { function ZoomControlButton({ command, title, icon, children, dismiss }: { command: KeyboardActionNames, title: string, icon?: string, children?: ComponentChildren, dismiss?: boolean }) {
const linkRef = useRef<HTMLAnchorElement>(null); const linkRef = useRef<HTMLAnchorElement>(null);
useStaticTooltipWithKeyboardShortcut(linkRef, title, command, { useStaticTooltipWithKeyboardShortcut(linkRef, title, command, {
placement: "bottom", placement: "bottom",
@ -167,8 +167,10 @@ function ZoomControls({ parentComponent }: { parentComponent?: Component | null
tabIndex={0} tabIndex={0}
onClick={(e) => { onClick={(e) => {
parentComponent?.triggerCommand(command); parentComponent?.triggerCommand(command);
setTimeout(() => updateZoomState(), 300) setTimeout(() => updateZoomState(), 300);
e.stopPropagation(); if (!dismiss) {
e.stopPropagation();
}
}} }}
className={`dropdown-item-button ${icon}`} className={`dropdown-item-button ${icon}`}
>{children}</a> >{children}</a>
@ -184,7 +186,7 @@ function ZoomControls({ parentComponent }: { parentComponent?: Component | null
{t("global_menu.zoom")} {t("global_menu.zoom")}
<> <>
<div className="zoom-buttons"> <div className="zoom-buttons">
<ZoomControlButton command="toggleFullscreen" title={t("global_menu.toggle_fullscreen")} icon="bx bx-expand-alt" /> <ZoomControlButton command="toggleFullscreen" title={t("global_menu.toggle_fullscreen")} icon="bx bx-expand-alt" dismiss />
&nbsp; &nbsp;
<ZoomControlButton command="zoomOut" title={t("global_menu.zoom_out")} icon="bx bx-minus" /> <ZoomControlButton command="zoomOut" title={t("global_menu.zoom_out")} icon="bx bx-minus" />
<ZoomControlButton command="zoomReset" title={t("global_menu.reset_zoom_level")}>{zoomLevel}{t("units.percentage")}</ZoomControlButton> <ZoomControlButton command="zoomReset" title={t("global_menu.reset_zoom_level")}>{zoomLevel}{t("units.percentage")}</ZoomControlButton>