Fix major rework on view (#2262)

This commit is contained in:
Charles Bochet
2023-10-27 15:30:52 +02:00
committed by GitHub
parent 53e51aad52
commit ec3327ca81
11 changed files with 269 additions and 189 deletions

View File

@ -1,8 +1,11 @@
import { useRecoilCallback } from 'recoil';
import { currentHotkeyScopeState } from '@/ui/utilities/hotkey/states/internal/currentHotkeyScopeState';
import { currentTableCellInEditModePositionState } from '../states/currentTableCellInEditModePositionState';
import { isTableCellInEditModeFamilyState } from '../states/isTableCellInEditModeFamilyState';
import { useSetSoftFocusOnCurrentTableCell } from '../table-cell/hooks/useSetSoftFocusOnCurrentTableCell';
import { TableHotkeyScope } from '../types/TableHotkeyScope';
export const useMoveSoftFocusToCurrentCellOnHover = () => {
const setSoftFocusOnCurrentTableCell = useSetSoftFocusOnCurrentTableCell();
@ -18,6 +21,17 @@ export const useMoveSoftFocusToCurrentCellOnHover = () => {
isTableCellInEditModeFamilyState(currentTableCellInEditModePosition),
);
const currentHotkeyScope = snapshot
.getLoadable(currentHotkeyScopeState)
.valueOrThrow();
if (
currentHotkeyScope.scope !== TableHotkeyScope.TableSoftFocus &&
currentHotkeyScope.scope !== TableHotkeyScope.CellEditMode
) {
return;
}
if (!isSomeCellInEditMode.contents) {
setSoftFocusOnCurrentTableCell();
}