Fix command menu selection (#10248)

- Created a state `hasUserSelectedCommandState` : This state is set to
`true` when the user selects an element in the command menu list. It is
set to false upon redirection or when the command menu is closed.
- Modified `CommandMenuDefaultSelectionEffect` to have the expected
selection behavior for the command menu
This commit is contained in:
Raphaël Bosi
2025-02-17 12:02:17 +01:00
committed by GitHub
parent 14478afa7e
commit 7ed142e987
6 changed files with 44 additions and 4 deletions

View File

@ -13,6 +13,7 @@ import {
} from '@/command-menu/states/commandMenuNavigationStackState';
import { commandMenuPageState } from '@/command-menu/states/commandMenuPageState';
import { commandMenuPageInfoState } from '@/command-menu/states/commandMenuPageTitle';
import { hasUserSelectedCommandState } from '@/command-menu/states/hasUserSelectedCommandState';
import { CommandMenuPages } from '@/command-menu/types/CommandMenuPages';
import { contextStoreCurrentViewTypeComponentState } from '@/context-store/states/contextStoreCurrentViewTypeComponentState';
import { contextStoreFiltersComponentState } from '@/context-store/states/contextStoreFiltersComponentState';
@ -60,6 +61,7 @@ export const useCommandMenu = () => {
set(isCommandMenuOpenedState, true);
setHotkeyScopeAndMemorizePreviousScope(AppHotkeyScope.CommandMenuOpen);
set(hasUserSelectedCommandState, false);
},
[
copyContextStoreStates,
@ -89,6 +91,7 @@ export const useCommandMenu = () => {
set(commandMenuSearchState, '');
set(commandMenuNavigationStackState, []);
resetSelectedItem();
set(hasUserSelectedCommandState, false);
goBackToPreviousHotkeyScope();
emitRightDrawerCloseEvent();
@ -173,6 +176,7 @@ export const useCommandMenu = () => {
});
set(commandMenuNavigationStackState, newNavigationStack);
set(hasUserSelectedCommandState, false);
};
},
[closeCommandMenu],
@ -201,6 +205,8 @@ export const useCommandMenu = () => {
title: newNavigationStackItem?.pageTitle,
Icon: newNavigationStackItem?.pageIcon,
});
set(hasUserSelectedCommandState, false);
};
}, []);
@ -270,6 +276,8 @@ export const useCommandMenu = () => {
title: undefined,
Icon: undefined,
});
set(hasUserSelectedCommandState, false);
};
},
[copyContextStoreStates],