Skip to content

The open alternative to Salesforce, designed for AI.

Fix shortcuts inconsistencies (#12624)

Raphaël Bosied1593c089e4
diff --git a/packages/twenty-front/src/modules/app/effect-components/PageChangeEffect.tsx b/packages/twenty-front/src/modules/app/effect-components/PageChangeEffect.tsx
index b77097342b5..b97388bb53e 100644
--- a/packages/twenty-front/src/modules/app/effect-components/PageChangeEffect.tsx
+++ b/packages/twenty-front/src/modules/app/effect-components/PageChangeEffect.tsx
@@ -147,6 +147,7 @@ export const PageChangeEffect = () => {
setHotkeyScope(RecordIndexHotkeyScope.RecordIndex, {
goto: true,
keyboardShortcutMenu: true,
+ searchRecords: true,
});
break;
}
@@ -154,6 +155,7 @@ export const PageChangeEffect = () => {
setHotkeyScope(PageHotkeyScope.RecordShowPage, {
goto: true,
keyboardShortcutMenu: true,
+ searchRecords: true,
});
break;
}
@@ -191,6 +193,7 @@ export const PageChangeEffect = () => {
keyboardShortcutMenu: false,
commandMenu: false,
commandMenuOpen: false,
+ searchRecords: false,
});
break;
}
diff --git a/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuHotKeys.ts b/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuHotKeys.ts
index 3c1ca566246..9f019dab0d4 100644
--- a/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuHotKeys.ts
+++ b/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuHotKeys.ts
@@ -53,7 +53,7 @@ export const useCommandMenuHotKeys = () => {
openRecordsSearchPage();
},
false,
- AppHotkeyScope.KeyboardShortcutMenu,
+ AppHotkeyScope.SearchRecords,
[openRecordsSearchPage],
{
ignoreModifiers: true,
diff --git a/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoardHotkeyEffect.tsx b/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoardHotkeyEffect.tsx
index f8eef8feaac..d60c71cb78b 100644
--- a/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoardHotkeyEffect.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoardHotkeyEffect.tsx
@@ -13,6 +13,12 @@ import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotV
import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2';
import { useRecoilCallback } from 'recoil';
+const BOARD_NAVIGATION_CUSTOM_SCOPES = {
+ goto: true,
+ keyboardShortcutMenu: true,
+ searchRecords: true,
+};
+
export const RecordBoardHotkeyEffect = () => {
const { recordBoardId } = useContext(RecordBoardContext);
@@ -54,6 +60,7 @@ export const RecordBoardHotkeyEffect = () => {
() => {
setHotkeyScopeAndMemorizePreviousScope({
scope: BoardHotkeyScope.BoardFocus,
+ customScopes: BOARD_NAVIGATION_CUSTOM_SCOPES,
});
move('left');
},
@@ -65,6 +72,7 @@ export const RecordBoardHotkeyEffect = () => {
() => {
setHotkeyScopeAndMemorizePreviousScope({
scope: BoardHotkeyScope.BoardFocus,
+ customScopes: BOARD_NAVIGATION_CUSTOM_SCOPES,
});
move('right');
},
@@ -76,6 +84,7 @@ export const RecordBoardHotkeyEffect = () => {
() => {
setHotkeyScopeAndMemorizePreviousScope({
scope: BoardHotkeyScope.BoardFocus,
+ customScopes: BOARD_NAVIGATION_CUSTOM_SCOPES,
});
move('up');
},
@@ -87,6 +96,7 @@ export const RecordBoardHotkeyEffect = () => {
() => {
setHotkeyScopeAndMemorizePreviousScope({
scope: BoardHotkeyScope.BoardFocus,
+ customScopes: BOARD_NAVIGATION_CUSTOM_SCOPES,
});
move('down');
},
diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/useMapKeyboardToFocus.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/useMapKeyboardToFocus.ts
index 0b1ef505d27..7311849d256 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/useMapKeyboardToFocus.ts
+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/useMapKeyboardToFocus.ts
@@ -5,6 +5,12 @@ import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousH
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
import { Key } from 'ts-key-enum';
+const TABLE_NAVIGATION_CUSTOM_SCOPES = {
+ goto: true,
+ keyboardShortcutMenu: true,
+ searchRecords: true,
+};
+
export const useMapKeyboardToFocus = (recordTableId?: string) => {
const { setHotkeyScopeAndMemorizePreviousScope } = usePreviousHotkeyScope();
@@ -33,6 +39,7 @@ export const useMapKeyboardToFocus = (recordTableId?: string) => {
() => {
setHotkeyScopeAndMemorizePreviousScope({
scope: TableHotkeyScope.TableFocus,
+ customScopes: TABLE_NAVIGATION_CUSTOM_SCOPES,
});
move('up');
},
@@ -45,6 +52,7 @@ export const useMapKeyboardToFocus = (recordTableId?: string) => {
() => {
setHotkeyScopeAndMemorizePreviousScope({
scope: TableHotkeyScope.TableFocus,
+ customScopes: TABLE_NAVIGATION_CUSTOM_SCOPES,
});
move('down');
},
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-body/components/RecordTableBodyFocusClickOutsideEffect.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-body/components/RecordTableBodyFocusClickOutsideEffect.tsx
index 0b617d834c8..5d6229b1e80 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-body/components/RecordTableBodyFocusClickOutsideEffect.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-body/components/RecordTableBodyFocusClickOutsideEffect.tsx
@@ -44,7 +44,11 @@ export const RecordTableBodyFocusClickOutsideEffect = ({
}
leaveTableFocus();
- setHotkeyScope(RecordIndexHotkeyScope.RecordIndex);
+ setHotkeyScope(RecordIndexHotkeyScope.RecordIndex, {
+ goto: true,
+ keyboardShortcutMenu: true,
+ searchRecords: true,
+ });
},
});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-body/components/RecordTableBodyFocusKeyboardEffect.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-body/components/RecordTableBodyFocusKeyboardEffect.tsx
index fac0a63929d..b0d74609cd7 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-body/components/RecordTableBodyFocusKeyboardEffect.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-body/components/RecordTableBodyFocusKeyboardEffect.tsx
@@ -37,6 +37,7 @@ export const RecordTableBodyFocusKeyboardEffect = () => {
setHotkeyScope(RecordIndexHotkeyScope.RecordIndex, {
goto: true,
keyboardShortcutMenu: true,
+ searchRecords: true,
});
}
},
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/__tests__/useCloseRecordTableCellInGroup.test.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/__tests__/useCloseRecordTableCellInGroup.test.tsx
index c6b6edd1890..50a00e67bfd 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/__tests__/useCloseRecordTableCellInGroup.test.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/__tests__/useCloseRecordTableCellInGroup.test.tsx
@@ -94,6 +94,10 @@ describe('useCloseRecordTableCellInGroup', () => {
expect(result.current.isDragSelectionStartEnabled()).toBe(true);
expect(result.current.currentTableCellInEditModePosition).toBe(null);
- expect(setHotkeyScope).toHaveBeenCalledWith('table-focus');
+ expect(setHotkeyScope).toHaveBeenCalledWith('table-focus', {
+ goto: true,
+ keyboardShortcutMenu: true,
+ searchRecords: true,
+ });
});
});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/__tests__/useCloseRecordTableCellNoGroup.test.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/__tests__/useCloseRecordTableCellNoGroup.test.tsx
index 9045267ec6e..dfce054b73d 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/__tests__/useCloseRecordTableCellNoGroup.test.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/__tests__/useCloseRecordTableCellNoGroup.test.tsx
@@ -95,6 +95,10 @@ describe('useCloseRecordTableCellNoGroup', () => {
expect(result.current.isDragSelectionStartEnabled()).toBe(true);
expect(result.current.currentTableCellInEditModePosition).toBe(null);
- expect(setHotkeyScope).toHaveBeenCalledWith('table-focus');
+ expect(setHotkeyScope).toHaveBeenCalledWith('table-focus', {
+ goto: true,
+ keyboardShortcutMenu: true,
+ searchRecords: true,
+ });
});
});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/useCloseRecordTableCellInGroup.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/useCloseRecordTableCellInGroup.ts
index 57fecfd139b..f045bea065e 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/useCloseRecordTableCellInGroup.ts
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/useCloseRecordTableCellInGroup.ts
@@ -27,7 +27,11 @@ export const useCloseRecordTableCellInGroup = () => {
toggleClickOutside(true);
setDragSelectionStartEnabled(true);
closeCurrentTableCellInEditMode();
- setHotkeyScope(TableHotkeyScope.TableFocus);
+ setHotkeyScope(TableHotkeyScope.TableFocus, {
+ goto: true,
+ keyboardShortcutMenu: true,
+ searchRecords: true,
+ });
},
[
closeCurrentTableCellInEditMode,
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/useCloseRecordTableCellNoGroup.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/useCloseRecordTableCellNoGroup.ts
index fa968f72daa..38a583bb231 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/useCloseRecordTableCellNoGroup.ts
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/internal/useCloseRecordTableCellNoGroup.ts
@@ -26,7 +26,11 @@ export const useCloseRecordTableCellNoGroup = () => {
toggleClickOutside(true);
setDragSelectionStartEnabled(true);
closeCurrentTableCellInEditMode();
- setHotkeyScope(TableHotkeyScope.TableFocus);
+ setHotkeyScope(TableHotkeyScope.TableFocus, {
+ goto: true,
+ keyboardShortcutMenu: true,
+ searchRecords: true,
+ });
}, [
closeCurrentTableCellInEditMode,
setDragSelectionStartEnabled,
diff --git a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts
index f1392bd0e01..42bbe3a14e7 100644
--- a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts
@@ -19,7 +19,9 @@ const areCustomScopesEqual = (
customScopesA?.commandMenu === customScopesB?.commandMenu &&
customScopesA?.commandMenuOpen === customScopesB?.commandMenuOpen &&
customScopesA?.goto === customScopesB?.goto &&
- customScopesA?.keyboardShortcutMenu === customScopesB?.keyboardShortcutMenu
+ customScopesA?.keyboardShortcutMenu ===
+ customScopesB?.keyboardShortcutMenu &&
+ customScopesA?.searchRecords === customScopesB?.searchRecords
);
};
@@ -60,6 +62,7 @@ export const useSetHotkeyScope = () =>
commandMenuOpen: customScopes?.commandMenuOpen ?? true,
goto: customScopes?.goto ?? false,
keyboardShortcutMenu: customScopes?.keyboardShortcutMenu ?? false,
+ searchRecords: customScopes?.searchRecords ?? false,
},
};
@@ -81,6 +84,10 @@ export const useSetHotkeyScope = () =>
scopesToSet.push(AppHotkeyScope.KeyboardShortcutMenu);
}
+ if (newHotkeyScope?.customScopes?.searchRecords === true) {
+ scopesToSet.push(AppHotkeyScope.SearchRecords);
+ }
+
scopesToSet.push(newHotkeyScope.scope);
if (DEBUG_HOTKEY_SCOPE) {
diff --git a/packages/twenty-front/src/modules/ui/utilities/hotkey/types/AppHotkeyScope.ts b/packages/twenty-front/src/modules/ui/utilities/hotkey/types/AppHotkeyScope.ts
index 9fc1a460ec6..60e7d9d92a0 100644
--- a/packages/twenty-front/src/modules/ui/utilities/hotkey/types/AppHotkeyScope.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/hotkey/types/AppHotkeyScope.ts
@@ -3,6 +3,7 @@ export enum AppHotkeyScope {
Goto = 'goto',
CommandMenu = 'command-menu',
CommandMenuOpen = 'command-menu-open',
+ SearchRecords = 'search-records',
KeyboardShortcutMenu = 'keyboard-shortcut-menu',
KeyboardShortcutMenuOpen = 'keyboard-shortcut-menu-open',
}
diff --git a/packages/twenty-front/src/modules/ui/utilities/hotkey/types/CustomHotkeyScope.ts b/packages/twenty-front/src/modules/ui/utilities/hotkey/types/CustomHotkeyScope.ts
index f3b14304965..49d02d2a6f9 100644
--- a/packages/twenty-front/src/modules/ui/utilities/hotkey/types/CustomHotkeyScope.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/hotkey/types/CustomHotkeyScope.ts
@@ -3,4 +3,5 @@ export type CustomHotkeyScopes = {
commandMenu?: boolean;
commandMenuOpen?: boolean;
keyboardShortcutMenu?: boolean;
+ searchRecords?: boolean;
};