Replace hotkey scopes by focus stack (Part 2 - Record Table, Rows and Cells) (#12798)
# Replace hotkey scopes by focus stack (Part 2 - Record Table, Rows and Cells) This PR is the second part of a refactoring aiming to deprecate the hotkey scopes api in favor of the new focus stack api which is more robust. Part 1: https://github.com/twentyhq/twenty/pull/12673 The record table shortcuts are no longer centralized in the record table, they now split and the focused element is in charge of applying the desired shortcuts. (For instance: The rows are in charge of the row navigation and the cells of the cells navigation). ## Video QA: https://github.com/user-attachments/assets/f0bb9eed-8a2a-4b6d-a82f-1998e929f122 ## Bugfixes: ### Fix record table click outside not working after opening and closing a cell Introduced by https://github.com/twentyhq/twenty/pull/11644 #### Before https://github.com/user-attachments/assets/d28deda8-15e9-4ffe-b60a-e8b54625f8e5 #### After https://github.com/user-attachments/assets/3f7e1ffc-15d9-4336-aeb0-bebd8ae0cbe0 ### Fix ObjectFilterDropdownFilterInput hotkeys Introduced by https://github.com/twentyhq/twenty/pull/12673 #### Before https://github.com/user-attachments/assets/ab2039bd-ebe1-49ba-8377-a6b300664469 #### After https://github.com/user-attachments/assets/90597453-dab2-426b-a134-0a24b0de0a6b
This commit is contained in:
@ -24,7 +24,7 @@ import { CoreObjectNamePlural } from '@/object-metadata/types/CoreObjectNamePlur
|
||||
import { useActiveRecordBoardCard } from '@/object-record/record-board/hooks/useActiveRecordBoardCard';
|
||||
import { useFocusedRecordBoardCard } from '@/object-record/record-board/hooks/useFocusedRecordBoardCard';
|
||||
import { useRecordBoardSelection } from '@/object-record/record-board/hooks/useRecordBoardSelection';
|
||||
import { RecordIndexHotkeyScope } from '@/object-record/record-index/types/RecordIndexHotkeyScope';
|
||||
import { useResetFocusStackToRecordIndex } from '@/object-record/record-index/hooks/useResetFocusStackToRecordIndex';
|
||||
import { useResetTableRowSelection } from '@/object-record/record-table/hooks/internal/useResetTableRowSelection';
|
||||
import { useActiveRecordTableRow } from '@/object-record/record-table/hooks/useActiveRecordTableRow';
|
||||
import { useFocusedRecordTableRow } from '@/object-record/record-table/hooks/useFocusedRecordTableRow';
|
||||
@ -40,6 +40,7 @@ import { usePageChangeEffectNavigateLocation } from '~/hooks/usePageChangeEffect
|
||||
import { useInitializeQueryParamState } from '~/modules/app/hooks/useInitializeQueryParamState';
|
||||
import { isMatchingLocation } from '~/utils/isMatchingLocation';
|
||||
import { getPageTitleFromPath } from '~/utils/title-utils';
|
||||
|
||||
// TODO: break down into smaller functions and / or hooks
|
||||
// - moved usePageChangeEffectNavigateLocation into dedicated hook
|
||||
export const PageChangeEffect = () => {
|
||||
@ -91,6 +92,8 @@ export const PageChangeEffect = () => {
|
||||
|
||||
const { closeCommandMenu } = useCommandMenu();
|
||||
|
||||
const { resetFocusStackToRecordIndex } = useResetFocusStackToRecordIndex();
|
||||
|
||||
useEffect(() => {
|
||||
closeCommandMenu();
|
||||
}, [location.pathname, closeCommandMenu]);
|
||||
@ -130,25 +133,10 @@ export const PageChangeEffect = () => {
|
||||
unfocusBoardCard();
|
||||
}
|
||||
}
|
||||
}, [
|
||||
previousLocation,
|
||||
resetTableSelections,
|
||||
unfocusRecordTableRow,
|
||||
deactivateRecordTableRow,
|
||||
contextStoreCurrentViewType,
|
||||
resetRecordSelection,
|
||||
deactivateBoardCard,
|
||||
unfocusBoardCard,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
switch (true) {
|
||||
case isMatchingLocation(location, AppPath.RecordIndexPage): {
|
||||
setHotkeyScope(RecordIndexHotkeyScope.RecordIndex, {
|
||||
goto: true,
|
||||
keyboardShortcutMenu: true,
|
||||
searchRecords: true,
|
||||
});
|
||||
resetFocusStackToRecordIndex();
|
||||
break;
|
||||
}
|
||||
case isMatchingLocation(location, AppPath.RecordShowPage): {
|
||||
@ -198,7 +186,19 @@ export const PageChangeEffect = () => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, [location, setHotkeyScope]);
|
||||
}, [
|
||||
location,
|
||||
setHotkeyScope,
|
||||
previousLocation,
|
||||
contextStoreCurrentViewType,
|
||||
resetTableSelections,
|
||||
unfocusRecordTableRow,
|
||||
deactivateRecordTableRow,
|
||||
resetRecordSelection,
|
||||
deactivateBoardCard,
|
||||
unfocusBoardCard,
|
||||
resetFocusStackToRecordIndex,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
|
||||
Reference in New Issue
Block a user