feat(settings): don't navigate to submenu of non opened menu

This commit is contained in:
2026-01-31 00:05:47 +01:00
parent c5b3e0ad7d
commit 10f7d16805
2 changed files with 11 additions and 0 deletions

View File

@@ -134,6 +134,13 @@ const { select, selected, selectorPosition } = useButtonNavigation({
left: "user", left: "user",
}, },
}, },
canClickButton: (buttonName) => {
if (isSubMenu(buttonName)) {
const parent = getParentMenu(buttonName);
return settingsStore.currentMenu === parent && settingsStore.menuExpanded;
}
return true;
},
disabled: computed(() => settingsStore.currentSubMenu !== null), disabled: computed(() => settingsStore.currentSubMenu !== null),
selectorAnimation: { selectorAnimation: {
duration: 0.11, duration: 0.11,

View File

@@ -3,6 +3,7 @@ import gsap from "gsap";
export const useButtonNavigation = <T extends Record<string, Rect>>({ export const useButtonNavigation = <T extends Record<string, Rect>>({
buttons, buttons,
initialButton, initialButton,
canClickButton,
onButtonClick, onButtonClick,
navigation, navigation,
disabled, disabled,
@@ -10,6 +11,7 @@ export const useButtonNavigation = <T extends Record<string, Rect>>({
}: { }: {
buttons: T; buttons: T;
initialButton: keyof T; initialButton: keyof T;
canClickButton?: (buttonName: keyof T) => boolean;
onButtonClick?: (buttonName: keyof T) => void; onButtonClick?: (buttonName: keyof T) => void;
navigation: Record< navigation: Record<
keyof T, keyof T,
@@ -188,6 +190,8 @@ export const useButtonNavigation = <T extends Record<string, Rect>>({
][]) { ][]) {
const [sx, sy, sw, sh] = buttonRect; const [sx, sy, sw, sh] = buttonRect;
if (x >= sx && x <= sx + sw && y >= sy && y <= sy + sh) { if (x >= sx && x <= sx + sw && y >= sy && y <= sy + sh) {
if (canClickButton && !canClickButton(buttonName)) continue;
if (selectedButton.value === buttonName) { if (selectedButton.value === buttonName) {
onButtonClick?.(buttonName); onButtonClick?.(buttonName);
} else { } else {