608 fix hotkey scope and dropdown issues in the command menu (#11121)

Closes https://github.com/twentyhq/core-team-issues/issues/608

- Introduces a new hotkey scope `CommandMenuFocused`
- Fixes hotkey scopes issues in the side panel
This commit is contained in:
Raphaël Bosi
2025-03-24 15:34:09 +01:00
committed by GitHub
parent 6898a40ac3
commit 0084946b76
10 changed files with 45 additions and 36 deletions

View File

@ -62,7 +62,7 @@ export const useDropdownV2 = () => {
const toggleDropdown = useRecoilCallback(
({ snapshot }) =>
(specificComponentId: string) => {
(specificComponentId: string, customHotkeyScope?: HotkeyScope) => {
const scopeId = getScopeIdFromComponentId(specificComponentId);
const isDropdownOpen = snapshot
.getLoadable(isDropdownOpenComponentState({ scopeId }))
@ -71,7 +71,7 @@ export const useDropdownV2 = () => {
if (isDropdownOpen) {
closeDropdown(specificComponentId);
} else {
openDropdown(specificComponentId);
openDropdown(specificComponentId, customHotkeyScope);
}
},
[closeDropdown, openDropdown],

View File

@ -3,13 +3,13 @@ import { useRecoilCallback } from 'recoil';
import { DEBUG_HOTKEY_SCOPE } from '@/ui/utilities/hotkey/hooks/useScopedHotkeyCallback';
import { logDebug } from '~/utils/logDebug';
import { isDefined } from 'twenty-shared/utils';
import { DEFAULT_HOTKEYS_SCOPE_CUSTOM_SCOPES } from '../constants/DefaultHotkeysScopeCustomScopes';
import { currentHotkeyScopeState } from '../states/internal/currentHotkeyScopeState';
import { internalHotkeysEnabledScopesState } from '../states/internal/internalHotkeysEnabledScopesState';
import { AppHotkeyScope } from '../types/AppHotkeyScope';
import { CustomHotkeyScopes } from '../types/CustomHotkeyScope';
import { HotkeyScope } from '../types/HotkeyScope';
import { isDefined } from 'twenty-shared/utils';
const isCustomScopesEqual = (
customScopesA: CustomHotkeyScopes | undefined,
@ -69,6 +69,10 @@ export const useSetHotkeyScope = () =>
scopesToSet.push(AppHotkeyScope.CommandMenu);
}
if (newHotkeyScope.customScopes?.commandMenuOpen === true) {
scopesToSet.push(AppHotkeyScope.CommandMenuOpen);
}
if (newHotkeyScope?.customScopes?.goto === true) {
scopesToSet.push(AppHotkeyScope.Goto);
}