Fixed hotkey bug with Select component and added debug logs for hotkeys (#4879)

- Select component was adding a duplicate useListenClickOutside already
present in useDropdown for closing dropdown.
- Added debug logs for hotkeys scopes
This commit is contained in:
Lucas Bordeau
2024-04-08 17:08:30 +02:00
committed by GitHub
parent 038b2c0efc
commit 97f9fc3f81
5 changed files with 35 additions and 13 deletions

View File

@ -1,5 +1,8 @@
import { useRecoilCallback } from 'recoil';
import { DEBUG_HOTKEY_SCOPE } from '@/ui/utilities/hotkey/hooks/useScopedHotkeyCallback';
import { logDebug } from '~/utils/logDebug';
import { currentHotkeyScopeState } from '../states/internal/currentHotkeyScopeState';
import { previousHotkeyScopeState } from '../states/internal/previousHotkeyScopeState';
import { CustomHotkeyScopes } from '../types/CustomHotkeyScope';
@ -20,6 +23,11 @@ export const usePreviousHotkeyScope = () => {
return;
}
// eslint-disable-next-line @nx/workspace-explicit-boolean-predicates-in-if
if (DEBUG_HOTKEY_SCOPE) {
logDebug('DEBUG: goBackToPreviousHotkeyScope', previousHotkeyScope);
}
setHotkeyScope(
previousHotkeyScope.scope,
previousHotkeyScope.customScopes,
@ -37,6 +45,15 @@ export const usePreviousHotkeyScope = () => {
.getLoadable(currentHotkeyScopeState)
.getValue();
// eslint-disable-next-line @nx/workspace-explicit-boolean-predicates-in-if
if (DEBUG_HOTKEY_SCOPE) {
logDebug('DEBUG: setHotkeyScopeAndMemorizePreviousScope', {
currentHotkeyScope,
scope,
customScopes,
});
}
setHotkeyScope(scope, customScopes);
set(previousHotkeyScopeState, currentHotkeyScope);
},