2982-feat: Clear SelectableList reset scoped state (#2987)

* 2982-feat: Clear SelectableList reset scoped state

* State fixes as suggested in pr

* State fixes as suggested in pr

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Kanav Arora
2023-12-15 23:06:32 +05:30
committed by GitHub
parent 3ac4102c3c
commit 2ea0e0c4e8
2 changed files with 18 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import { useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import { useRecoilCallback, useSetRecoilState } from 'recoil';
import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';
@ -14,6 +15,9 @@ export const useCommandMenu = () => {
const navigate = useNavigate();
const setIsCommandMenuOpened = useSetRecoilState(isCommandMenuOpenedState);
const setCommands = useSetRecoilState(commandMenuCommandsState);
const { resetSelectedItem } = useSelectableList({
selectableListId: 'command-menu-list',
});
const {
setHotkeyScopeAndMemorizePreviousScope,
goBackToPreviousHotkeyScope,
@ -26,6 +30,7 @@ export const useCommandMenu = () => {
const closeCommandMenu = () => {
setIsCommandMenuOpened(false);
resetSelectedItem();
goBackToPreviousHotkeyScope();
};