Update previousHotkeyScopeState to be a family state (#11270)
Fixes #11259
This commit is contained in:
@ -28,7 +28,9 @@ import { useRecoilCallback } from 'recoil';
|
|||||||
export const useCommandMenuCloseAnimationCompleteCleanup = () => {
|
export const useCommandMenuCloseAnimationCompleteCleanup = () => {
|
||||||
const { resetSelectedItem } = useSelectableList('command-menu-list');
|
const { resetSelectedItem } = useSelectableList('command-menu-list');
|
||||||
|
|
||||||
const { goBackToPreviousHotkeyScope } = usePreviousHotkeyScope();
|
const { goBackToPreviousHotkeyScope } = usePreviousHotkeyScope(
|
||||||
|
COMMAND_MENU_COMPONENT_INSTANCE_ID,
|
||||||
|
);
|
||||||
|
|
||||||
const { resetContextStoreStates } = useResetContextStoreStates();
|
const { resetContextStoreStates } = useResetContextStoreStates();
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,9 @@ export type CommandMenuNavigationStackItem = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const useNavigateCommandMenu = () => {
|
export const useNavigateCommandMenu = () => {
|
||||||
const { setHotkeyScopeAndMemorizePreviousScope } = usePreviousHotkeyScope();
|
const { setHotkeyScopeAndMemorizePreviousScope } = usePreviousHotkeyScope(
|
||||||
|
COMMAND_MENU_COMPONENT_INSTANCE_ID,
|
||||||
|
);
|
||||||
|
|
||||||
const { copyContextStoreStates } = useCopyContextStoreStates();
|
const { copyContextStoreStates } = useCopyContextStoreStates();
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
export const INLINE_CELL_HOTKEY_SCOPE_MEMOIZE_KEY = 'inline-cell';
|
||||||
@ -7,13 +7,14 @@ import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousH
|
|||||||
import { useInitDraftValueV2 } from '@/object-record/record-field/hooks/useInitDraftValueV2';
|
import { useInitDraftValueV2 } from '@/object-record/record-field/hooks/useInitDraftValueV2';
|
||||||
import { RecordFieldComponentInstanceContext } from '@/object-record/record-field/states/contexts/RecordFieldComponentInstanceContext';
|
import { RecordFieldComponentInstanceContext } from '@/object-record/record-field/states/contexts/RecordFieldComponentInstanceContext';
|
||||||
import { useRecordInlineCellContext } from '@/object-record/record-inline-cell/components/RecordInlineCellContext';
|
import { useRecordInlineCellContext } from '@/object-record/record-inline-cell/components/RecordInlineCellContext';
|
||||||
|
import { INLINE_CELL_HOTKEY_SCOPE_MEMOIZE_KEY } from '@/object-record/record-inline-cell/constants/InlineCellHotkeyScopeMemoizeKey';
|
||||||
import { getDropdownFocusIdForRecordField } from '@/object-record/utils/getDropdownFocusIdForRecordField';
|
import { getDropdownFocusIdForRecordField } from '@/object-record/utils/getDropdownFocusIdForRecordField';
|
||||||
import { useGoBackToPreviousDropdownFocusId } from '@/ui/layout/dropdown/hooks/useGoBackToPreviousDropdownFocusId';
|
import { useGoBackToPreviousDropdownFocusId } from '@/ui/layout/dropdown/hooks/useGoBackToPreviousDropdownFocusId';
|
||||||
import { useSetActiveDropdownFocusIdAndMemorizePrevious } from '@/ui/layout/dropdown/hooks/useSetFocusedDropdownIdAndMemorizePrevious';
|
import { useSetActiveDropdownFocusIdAndMemorizePrevious } from '@/ui/layout/dropdown/hooks/useSetFocusedDropdownIdAndMemorizePrevious';
|
||||||
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
|
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
|
||||||
|
import { isDefined } from 'twenty-shared/utils';
|
||||||
import { isInlineCellInEditModeScopedState } from '../states/isInlineCellInEditModeScopedState';
|
import { isInlineCellInEditModeScopedState } from '../states/isInlineCellInEditModeScopedState';
|
||||||
import { InlineCellHotkeyScope } from '../types/InlineCellHotkeyScope';
|
import { InlineCellHotkeyScope } from '../types/InlineCellHotkeyScope';
|
||||||
import { isDefined } from 'twenty-shared/utils';
|
|
||||||
|
|
||||||
export const useInlineCell = (
|
export const useInlineCell = (
|
||||||
recordFieldComponentInstanceIdFromProps?: string,
|
recordFieldComponentInstanceIdFromProps?: string,
|
||||||
@ -39,7 +40,7 @@ export const useInlineCell = (
|
|||||||
const {
|
const {
|
||||||
setHotkeyScopeAndMemorizePreviousScope,
|
setHotkeyScopeAndMemorizePreviousScope,
|
||||||
goBackToPreviousHotkeyScope,
|
goBackToPreviousHotkeyScope,
|
||||||
} = usePreviousHotkeyScope();
|
} = usePreviousHotkeyScope(INLINE_CELL_HOTKEY_SCOPE_MEMOIZE_KEY);
|
||||||
|
|
||||||
const initFieldInputDraftValue = useInitDraftValueV2();
|
const initFieldInputDraftValue = useInitDraftValueV2();
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { INLINE_CELL_HOTKEY_SCOPE_MEMOIZE_KEY } from '@/object-record/record-inline-cell/constants/InlineCellHotkeyScopeMemoizeKey';
|
||||||
import { isInlineCellInEditModeScopedState } from '@/object-record/record-inline-cell/states/isInlineCellInEditModeScopedState';
|
import { isInlineCellInEditModeScopedState } from '@/object-record/record-inline-cell/states/isInlineCellInEditModeScopedState';
|
||||||
import { InlineCellHotkeyScope } from '@/object-record/record-inline-cell/types/InlineCellHotkeyScope';
|
import { InlineCellHotkeyScope } from '@/object-record/record-inline-cell/types/InlineCellHotkeyScope';
|
||||||
import { getRecordTitleCellId } from '@/object-record/record-title-cell/utils/getRecordTitleCellId';
|
import { getRecordTitleCellId } from '@/object-record/record-title-cell/utils/getRecordTitleCellId';
|
||||||
@ -6,7 +7,6 @@ import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousH
|
|||||||
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
|
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
|
||||||
import { useRecoilCallback } from 'recoil';
|
import { useRecoilCallback } from 'recoil';
|
||||||
import { isDefined } from 'twenty-shared/utils';
|
import { isDefined } from 'twenty-shared/utils';
|
||||||
|
|
||||||
export const useRecordTitleCell = () => {
|
export const useRecordTitleCell = () => {
|
||||||
const { goBackToPreviousDropdownFocusId } =
|
const { goBackToPreviousDropdownFocusId } =
|
||||||
useGoBackToPreviousDropdownFocusId();
|
useGoBackToPreviousDropdownFocusId();
|
||||||
@ -14,7 +14,7 @@ export const useRecordTitleCell = () => {
|
|||||||
const {
|
const {
|
||||||
setHotkeyScopeAndMemorizePreviousScope,
|
setHotkeyScopeAndMemorizePreviousScope,
|
||||||
goBackToPreviousHotkeyScope,
|
goBackToPreviousHotkeyScope,
|
||||||
} = usePreviousHotkeyScope();
|
} = usePreviousHotkeyScope(INLINE_CELL_HOTKEY_SCOPE_MEMOIZE_KEY);
|
||||||
|
|
||||||
const closeRecordTitleCell = useRecoilCallback(
|
const closeRecordTitleCell = useRecoilCallback(
|
||||||
({ set }) =>
|
({ set }) =>
|
||||||
|
|||||||
@ -4,19 +4,19 @@ import { DEBUG_HOTKEY_SCOPE } from '@/ui/utilities/hotkey/hooks/useScopedHotkeyC
|
|||||||
import { logDebug } from '~/utils/logDebug';
|
import { logDebug } from '~/utils/logDebug';
|
||||||
|
|
||||||
import { currentHotkeyScopeState } from '../states/internal/currentHotkeyScopeState';
|
import { currentHotkeyScopeState } from '../states/internal/currentHotkeyScopeState';
|
||||||
import { previousHotkeyScopeState } from '../states/internal/previousHotkeyScopeState';
|
import { previousHotkeyScopeFamilyState } from '../states/internal/previousHotkeyScopeFamilyState';
|
||||||
import { CustomHotkeyScopes } from '../types/CustomHotkeyScope';
|
import { CustomHotkeyScopes } from '../types/CustomHotkeyScope';
|
||||||
|
|
||||||
import { useSetHotkeyScope } from './useSetHotkeyScope';
|
import { useSetHotkeyScope } from './useSetHotkeyScope';
|
||||||
|
|
||||||
export const usePreviousHotkeyScope = () => {
|
export const usePreviousHotkeyScope = (memoizeKey = 'global') => {
|
||||||
const setHotkeyScope = useSetHotkeyScope();
|
const setHotkeyScope = useSetHotkeyScope();
|
||||||
|
|
||||||
const goBackToPreviousHotkeyScope = useRecoilCallback(
|
const goBackToPreviousHotkeyScope = useRecoilCallback(
|
||||||
({ snapshot, set }) =>
|
({ snapshot, set }) =>
|
||||||
() => {
|
() => {
|
||||||
const previousHotkeyScope = snapshot
|
const previousHotkeyScope = snapshot
|
||||||
.getLoadable(previousHotkeyScopeState)
|
.getLoadable(previousHotkeyScopeFamilyState(memoizeKey))
|
||||||
.getValue();
|
.getValue();
|
||||||
|
|
||||||
if (!previousHotkeyScope) {
|
if (!previousHotkeyScope) {
|
||||||
@ -32,9 +32,9 @@ export const usePreviousHotkeyScope = () => {
|
|||||||
previousHotkeyScope.customScopes,
|
previousHotkeyScope.customScopes,
|
||||||
);
|
);
|
||||||
|
|
||||||
set(previousHotkeyScopeState, null);
|
set(previousHotkeyScopeFamilyState(memoizeKey), null);
|
||||||
},
|
},
|
||||||
[setHotkeyScope],
|
[setHotkeyScope, memoizeKey],
|
||||||
);
|
);
|
||||||
|
|
||||||
const setHotkeyScopeAndMemorizePreviousScope = useRecoilCallback(
|
const setHotkeyScopeAndMemorizePreviousScope = useRecoilCallback(
|
||||||
@ -53,9 +53,10 @@ export const usePreviousHotkeyScope = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setHotkeyScope(scope, customScopes);
|
setHotkeyScope(scope, customScopes);
|
||||||
set(previousHotkeyScopeState, currentHotkeyScope);
|
|
||||||
|
set(previousHotkeyScopeFamilyState(memoizeKey), currentHotkeyScope);
|
||||||
},
|
},
|
||||||
[setHotkeyScope],
|
[setHotkeyScope, memoizeKey],
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -0,0 +1,11 @@
|
|||||||
|
import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
|
||||||
|
|
||||||
|
import { HotkeyScope } from '../../types/HotkeyScope';
|
||||||
|
|
||||||
|
export const previousHotkeyScopeFamilyState = createFamilyState<
|
||||||
|
HotkeyScope | null,
|
||||||
|
string
|
||||||
|
>({
|
||||||
|
key: 'previousHotkeyScopeFamilyState',
|
||||||
|
defaultValue: null,
|
||||||
|
});
|
||||||
@ -1,8 +0,0 @@
|
|||||||
import { createState } from '@ui/utilities/state/utils/createState';
|
|
||||||
|
|
||||||
import { HotkeyScope } from '../../types/HotkeyScope';
|
|
||||||
|
|
||||||
export const previousHotkeyScopeState = createState<HotkeyScope | null>({
|
|
||||||
key: 'previousHotkeyScopeState',
|
|
||||||
defaultValue: null,
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user