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();
}

View File

@ -1,27 +1,21 @@
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope';
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
import { useView } from '@/views/hooks/useView';
import { TableOptionsDropdownId } from '../../constants/TableOptionsDropdownId';
import { TableOptionsHotkeyScope } from '../../types/TableOptionsHotkeyScope';
import { TableOptionsDropdownButton } from './TableOptionsDropdownButton';
import { TableOptionsDropdownContent } from './TableOptionsDropdownContent';
type TableOptionsDropdownProps = {
customHotkeyScope: HotkeyScope;
};
export const TableOptionsDropdown = ({
customHotkeyScope,
}: TableOptionsDropdownProps) => {
export const TableOptionsDropdown = () => {
const { setViewEditMode } = useView();
return (
<DropdownScope dropdownScopeId={TableOptionsDropdownId}>
<Dropdown
clickableComponent={<TableOptionsDropdownButton />}
dropdownHotkeyScope={customHotkeyScope}
dropdownHotkeyScope={{ scope: TableOptionsHotkeyScope.Dropdown }}
dropdownOffset={{ y: 8 }}
dropdownComponents={<TableOptionsDropdownContent />}
onClickOutside={() => setViewEditMode('none')}

View File

@ -81,6 +81,7 @@ export const TableOptionsDropdownContent = () => {
useScopedHotkeys(
Key.Enter,
() => {
console.log('enter');
const name = viewEditInputRef.current?.value;
handleViewNameSubmit(name);
resetMenu();