The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Add Keyboard navigation on IconPicker (#2778)
gitstart-twenty7c40dc7b8116
diff --git a/front/src/modules/command-menu/components/CommandMenu.tsx b/front/src/modules/command-menu/components/CommandMenu.tsxindex 2efb2233e30..9817a259ad2 100644--- a/front/src/modules/command-menu/components/CommandMenu.tsx+++ b/front/src/modules/command-menu/components/CommandMenu.tsx@@ -4,7 +4,6 @@ import { useRecoilValue } from 'recoil';import { useOpenActivityRightDrawer } from '@/activities/hooks/useOpenActivityRightDrawer';import { Activity } from '@/activities/types/Activity';-import { CommandMenuSelectableListEffect } from '@/command-menu/components/CommandMenuSelectableListEffect';import { Company } from '@/companies/types/Company';import { useKeyboardShortcutMenu } from '@/keyboard-shortcut-menu/hooks/useKeyboardShortcutMenu';import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';@@ -86,7 +85,7 @@ export const StyledEmpty = styled.div``;export const CommandMenu = () => {- const { toggleCommandMenu, closeCommandMenu } = useCommandMenu();+ const { toggleCommandMenu } = useCommandMenu();const openActivityRightDrawer = useOpenActivityRightDrawer();const isCommandMenuOpened = useRecoilValue(isCommandMenuOpenedState);@@ -109,17 +108,6 @@ export const CommandMenu = () => {[toggleCommandMenu, setSearch],);- useScopedHotkeys(- 'esc',- () => {- setSearch('');- closeKeyboardShortcutMenu();- closeCommandMenu();- },- AppHotkeyScope.CommandMenu,- [toggleCommandMenu, setSearch],- );-const { records: people } = useFindManyRecords<Person>({skip: !isCommandMenuOpened,objectNameSingular: 'person',@@ -198,12 +186,13 @@ export const CommandMenu = () => {<StyledList><ScrollWrapper><StyledInnerList>- <CommandMenuSelectableListEffect- selectableItemIds={selectableItemIds}- /><SelectableListselectableListId="command-menu-list"- selectableItemIds={selectableItemIds}+ selectableItemIds={[selectableItemIds]}+ hotkeyScope={AppHotkeyScope.CommandMenu}+ onEnter={(itemId) => {+ console.log(itemId);+ }}>{!matchingCreateCommand.length &&!matchingNavigateCommand.length &&diff --git a/front/src/modules/command-menu/components/CommandMenuItem.tsx b/front/src/modules/command-menu/components/CommandMenuItem.tsxindex 88f16517509..3a1f6afd3a9 100644--- a/front/src/modules/command-menu/components/CommandMenuItem.tsx+++ b/front/src/modules/command-menu/components/CommandMenuItem.tsx@@ -1,5 +1,3 @@-import { useNavigate } from 'react-router-dom';-import { IconArrowUpRight } from '@/ui/display/icon';import { IconComponent } from '@/ui/display/icon/types/IconComponent';import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';@@ -26,8 +24,7 @@ export const CommandMenuItem = ({firstHotKey,secondHotKey,}: CommandMenuItemProps) => {- const navigate = useNavigate();- const { toggleCommandMenu } = useCommandMenu();+ const { onItemClick } = useCommandMenu();if (to && !Icon) {Icon = IconArrowUpRight;@@ -35,26 +32,13 @@ export const CommandMenuItem = ({const { isSelectedItemId } = useSelectableList({ itemId: id });- const onItemClick = () => {- toggleCommandMenu();-- if (onClick) {- onClick();- return;- }- if (to) {- navigate(to);- return;- }- };-return (<MenuItemCommandLeftIcon={Icon}text={label}firstHotKey={firstHotKey}secondHotKey={secondHotKey}- onClick={onItemClick}+ onClick={() => onItemClick(onClick, to)}isSelected={isSelectedItemId}/>);diff --git a/front/src/modules/command-menu/components/CommandMenuSelectableListEffect.tsx b/front/src/modules/command-menu/components/CommandMenuSelectableListEffect.tsxdeleted file mode 100644index 200539e1eac..00000000000--- a/front/src/modules/command-menu/components/CommandMenuSelectableListEffect.tsx+++ /dev/null@@ -1,21 +0,0 @@-import { useEffect } from 'react';--import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';--type CommandMenuSelectableListEffectProps = {- selectableItemIds: string[];-};--export const CommandMenuSelectableListEffect = ({- selectableItemIds,-}: CommandMenuSelectableListEffectProps) => {- const { setSelectableItemIds } = useSelectableList({- selectableListId: 'command-menu-list',- });-- useEffect(() => {- setSelectableItemIds(selectableItemIds);- }, [selectableItemIds, setSelectableItemIds]);-- return <></>;-};diff --git a/front/src/modules/command-menu/hooks/useCommandMenu.ts b/front/src/modules/command-menu/hooks/useCommandMenu.tsindex 756415ed155..cf9af674733 100644--- a/front/src/modules/command-menu/hooks/useCommandMenu.ts+++ b/front/src/modules/command-menu/hooks/useCommandMenu.ts@@ -1,4 +1,5 @@import { useCallback } from 'react';+import { useNavigate } from 'react-router-dom';import { useRecoilCallback, useSetRecoilState } from 'recoil';import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';@@ -10,6 +11,7 @@ import { isCommandMenuOpenedState } from '../states/isCommandMenuOpenedState';import { Command } from '../types/Command';export const useCommandMenu = () => {+ const navigate = useNavigate();const setIsCommandMenuOpened = useSetRecoilState(isCommandMenuOpenedState);const setCommands = useSetRecoilState(commandMenuCommandsState);const {@@ -50,11 +52,28 @@ export const useCommandMenu = () => {setCommands(commandMenuCommands);};+ const onItemClick = useCallback(+ (onClick?: () => void, to?: string) => {+ toggleCommandMenu();++ if (onClick) {+ onClick();+ return;+ }+ if (to) {+ navigate(to);+ return;+ }+ },+ [navigate, toggleCommandMenu],+ );+return {openCommandMenu,closeCommandMenu,toggleCommandMenu,addToCommandMenu,+ onItemClick,setToIntitialCommandMenu,};};diff --git a/front/src/modules/ui/input/components/IconPicker.tsx b/front/src/modules/ui/input/components/IconPicker.tsxindex 9f707c61d9f..6f25f637e4d 100644--- a/front/src/modules/ui/input/components/IconPicker.tsx+++ b/front/src/modules/ui/input/components/IconPicker.tsx@@ -9,6 +9,10 @@ import { DropdownMenuSearchInput } from '@/ui/layout/dropdown/components/Dropdowimport { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator';import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';import { DropdownScope } from '@/ui/layout/dropdown/scopes/DropdownScope';+import { SelectableList } from '@/ui/layout/selectable-list/components/SelectableList';+import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';+import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';+import { arrayToChunks } from '~/utils/array/array-to-chunks';import { IconButton, IconButtonVariant } from '../button/components/IconButton';import { LightIconButton } from '../button/components/LightIconButton';@@ -44,6 +48,34 @@ const StyledLightIconButton = styled(LightIconButton)<{ isSelected?: boolean }>`const convertIconKeyToLabel = (iconKey: string) =>iconKey.replace(/[A-Z]/g, (letter) => ` ${letter}`).trim();+type IconPickerIconProps = {+ iconKey: string;+ onClick: () => void;+ selectedIconKey?: string;+ Icon: IconComponent;+};++const IconPickerIcon = ({+ iconKey,+ onClick,+ selectedIconKey,+ Icon,+}: IconPickerIconProps) => {+ const { isSelectedItemId } = useSelectableList({ itemId: iconKey });++ return (+ <StyledLightIconButton+ key={iconKey}+ aria-label={convertIconKeyToLabel(iconKey)}+ size="medium"+ title={iconKey}+ isSelected={iconKey === selectedIconKey || isSelectedItemId}+ Icon={Icon}+ onClick={onClick}+ />+ );+};+export const IconPicker = ({disabled,dropdownScopeId = 'icon-picker',@@ -56,6 +88,10 @@ export const IconPicker = ({className,}: IconPickerProps) => {const [searchString, setSearchString] = useState('');+ const {+ goBackToPreviousHotkeyScope,+ setHotkeyScopeAndMemorizePreviousScope,+ } = usePreviousHotkeyScope();const { closeDropdown } = useDropdown({ dropdownScopeId });@@ -79,6 +115,11 @@ export const IconPicker = ({).slice(0, 25);}, [icons, searchString, selectedIconKey]);+ const iconKeys2d = useMemo(+ () => arrayToChunks(iconKeys.slice(), 5),+ [iconKeys],+ );+return (<DropdownScope dropdownScopeId={dropdownScopeId}><div className={className}>@@ -93,36 +134,53 @@ export const IconPicker = ({}dropdownMenuWidth={176}dropdownComponents={- <DropdownMenu width={176}>- <DropdownMenuSearchInput- placeholder="Search icon"- autoFocus- onChange={(event) => setSearchString(event.target.value)}- />- <DropdownMenuSeparator />- <DropdownMenuItemsContainer>- {isLoading ? (- <DropdownMenuSkeletonItem />- ) : (- <StyledMenuIconItemsContainer>- {iconKeys.map((iconKey) => (- <StyledLightIconButton- key={iconKey}- aria-label={convertIconKeyToLabel(iconKey)}- isSelected={selectedIconKey === iconKey}- size="medium"- title={iconKey}- Icon={icons[iconKey]}- onClick={() => {- onChange({ iconKey, Icon: icons[iconKey] });- closeDropdown();- }}- />- ))}- </StyledMenuIconItemsContainer>- )}- </DropdownMenuItemsContainer>- </DropdownMenu>+ <SelectableList+ selectableListId="icon-list"+ selectableItemIds={iconKeys2d}+ hotkeyScope={IconPickerHotkeyScope.IconPicker}+ onEnter={(iconKey) => {+ onChange({ iconKey, Icon: icons[iconKey] });+ closeDropdown();+ }}+ >+ <DropdownMenu width={176}>+ <DropdownMenuSearchInput+ placeholder="Search icon"+ autoFocus+ onChange={(event) => setSearchString(event.target.value)}+ />+ <DropdownMenuSeparator />+ <div+ onMouseEnter={() => {+ setHotkeyScopeAndMemorizePreviousScope(+ IconPickerHotkeyScope.IconPicker,+ );+ }}+ onMouseLeave={goBackToPreviousHotkeyScope}+ >+ <DropdownMenuItemsContainer>+ {isLoading ? (+ <DropdownMenuSkeletonItem />+ ) : (+ <StyledMenuIconItemsContainer>+ {iconKeys.map((iconKey) => (+ <IconPickerIcon+ key={iconKey}+ iconKey={iconKey}+ onClick={() => {+ onChange({ iconKey, Icon: icons[iconKey] });+ closeDropdown();+ }}+ selectedIconKey={selectedIconKey}+ Icon={icons[iconKey]}+ />+ ))}+ </StyledMenuIconItemsContainer>+ )}+ </DropdownMenuItemsContainer>+ </div>+ </DropdownMenu>+ </SelectableList>}onClickOutside={onClickOutside}onClose={() => {diff --git a/front/src/modules/ui/layout/selectable-list/components/SelectableList.tsx b/front/src/modules/ui/layout/selectable-list/components/SelectableList.tsxindex 587644e7fa2..e65c499c078 100644--- a/front/src/modules/ui/layout/selectable-list/components/SelectableList.tsx+++ b/front/src/modules/ui/layout/selectable-list/components/SelectableList.tsx@@ -1,13 +1,17 @@-import { ReactNode } from 'react';+import { ReactNode, useEffect } from 'react';import styled from '@emotion/styled';import { useSelectableListHotKeys } from '@/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys';+import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';import { SelectableListScope } from '@/ui/layout/selectable-list/scopes/SelectableListScope';+type SelectableListProps = {children: ReactNode;selectableListId: string;- selectableItemIds: string[];+ selectableItemIds: string[][];onSelect?: (selected: string) => void;+ hotkeyScope: string;+ onEnter?: (itemId: string) => void;};const StyledSelectableItemsContainer = styled.div`@@ -17,8 +21,23 @@ const StyledSelectableItemsContainer = styled.div`export const SelectableList = ({children,selectableListId,+ hotkeyScope,+ selectableItemIds,+ onEnter,}: SelectableListProps) => {- useSelectableListHotKeys(selectableListId);+ useSelectableListHotKeys(selectableListId, hotkeyScope);++ const { setSelectableItemIds, setSelectableListOnEnter } = useSelectableList({+ selectableListId,+ });++ useEffect(() => {+ setSelectableListOnEnter(() => onEnter);+ }, [onEnter, setSelectableListOnEnter]);++ useEffect(() => {+ setSelectableItemIds(selectableItemIds);+ }, [selectableItemIds, setSelectableItemIds]);return (<SelectableListScope selectableListScopeId={selectableListId}>diff --git a/front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.tsx b/front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.tsxindex e491a407fd4..a8fb3385626 100644--- a/front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.tsx+++ b/front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.tsx@@ -1,16 +1,37 @@-import { isNull } from '@sniptt/guards';import { useRecoilCallback } from 'recoil';import { Key } from 'ts-key-enum';import { getSelectableListScopedStates } from '@/ui/layout/selectable-list/utils/internal/getSelectableListScopedStates';import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';-import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue';-export const useSelectableListHotKeys = (scopeId: string) => {+type Direction = 'up' | 'down' | 'left' | 'right';++export const useSelectableListHotKeys = (+ scopeId: string,+ hotkeyScope: string,+) => {+ const findPosition = (+ selectableItemIds: string[][],+ selectedItemId?: string | null,+ ) => {+ if (!selectedItemId) {+ // If nothing is selected, return the default position+ return { row: 0, col: 0 };+ }++ for (let row = 0; row < selectableItemIds.length; row++) {+ const col = selectableItemIds[row].indexOf(selectedItemId);+ if (col !== -1) {+ return { row, col };+ }+ }+ return { row: 0, col: 0 };+ };+const handleSelect = useRecoilCallback(({ snapshot, set }) =>- (direction: 'up' | 'down') => {+ (direction: Direction) => {const { selectedItemIdState, selectableItemIdsState } =getSelectableListScopedStates({selectableListScopeId: scopeId,@@ -21,31 +42,54 @@ export const useSelectableListHotKeys = (scopeId: string) => {selectableItemIdsState,);- const computeNextId = (direction: 'up' | 'down') => {+ const { row: currentRow, col: currentCol } = findPosition(+ selectableItemIds,+ selectedItemId,+ );++ const computeNextId = (direction: Direction) => {if (selectableItemIds.length === 0) {return;}- if (isNull(selectedItemId)) {- return direction === 'up'- ? selectableItemIds[selectableItemIds.length - 1]- : selectableItemIds[0];- }+ const isSingleRow = selectableItemIds.length === 1;++ let nextRow: number;+ let nextCol: number;- const currentIndex = selectableItemIds.indexOf(selectedItemId);- if (currentIndex === -1) {- return direction === 'up'- ? selectableItemIds[selectableItemIds.length - 1]- : selectableItemIds[0];+ switch (direction) {+ case 'up':+ nextRow = isSingleRow ? currentRow : Math.max(0, currentRow - 1);+ nextCol = isSingleRow ? Math.max(0, currentCol - 1) : currentCol;+ break;+ case 'down':+ nextRow = isSingleRow+ ? currentRow+ : Math.min(selectableItemIds.length - 1, currentRow + 1);+ nextCol = isSingleRow+ ? Math.min(+ selectableItemIds[currentRow].length - 1,+ currentCol + 1,+ )+ : currentCol;+ break;+ case 'left':+ nextRow = currentRow;+ nextCol = Math.max(0, currentCol - 1);+ break;+ case 'right':+ nextRow = currentRow;+ nextCol = Math.min(+ selectableItemIds[currentRow].length - 1,+ currentCol + 1,+ );+ break;+ default:+ nextRow = currentRow;+ nextCol = currentCol;}- return direction === 'up'- ? currentIndex == 0- ? selectableItemIds[selectableItemIds.length - 1]- : selectableItemIds[currentIndex - 1]- : currentIndex == selectableItemIds.length - 1- ? selectableItemIds[0]- : selectableItemIds[currentIndex + 1];+ return selectableItemIds[nextRow][nextCol];};const nextId = computeNextId(direction);@@ -70,17 +114,45 @@ export const useSelectableListHotKeys = (scopeId: string) => {[scopeId],);+ useScopedHotkeys(Key.ArrowUp, () => handleSelect('up'), hotkeyScope, []);++ useScopedHotkeys(Key.ArrowDown, () => handleSelect('down'), hotkeyScope, []);++ useScopedHotkeys(Key.ArrowLeft, () => handleSelect('left'), hotkeyScope, []);+useScopedHotkeys(- Key.ArrowUp,- () => handleSelect('up'),- AppHotkeyScope.CommandMenu,+ Key.ArrowRight,+ () => handleSelect('right'),+ hotkeyScope,[],);useScopedHotkeys(- Key.ArrowDown,- () => handleSelect('down'),- AppHotkeyScope.CommandMenu,+ Key.Enter,+ useRecoilCallback(+ ({ snapshot }) =>+ () => {+ const { selectedItemIdState, selectableListOnEnterState } =+ getSelectableListScopedStates({+ selectableListScopeId: scopeId,+ });+ const selectedItemId = getSnapshotValue(+ snapshot,+ selectedItemIdState,+ );++ const onEnter = getSnapshotValue(+ snapshot,+ selectableListOnEnterState,+ );++ if (selectedItemId) {+ onEnter?.(selectedItemId);+ }+ },+ [scopeId],+ ),+ hotkeyScope,[],);diff --git a/front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListScopedStates.ts b/front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListScopedStates.tsindex 885fd68e369..6afabd8a6ba 100644--- a/front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListScopedStates.ts+++ b/front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListScopedStates.ts@@ -20,6 +20,7 @@ export const useSelectableListScopedStates = (selectedItemIdState,selectableItemIdsState,isSelectedItemIdSelector,+ selectableListOnEnterState,} = getSelectableListScopedStates({selectableListScopeId: scopeId,itemId: itemId,@@ -30,5 +31,6 @@ export const useSelectableListScopedStates = (isSelectedItemIdSelector,selectableItemIdsState,selectedItemIdState,+ selectableListOnEnterState,};};diff --git a/front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts b/front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.tsindex b6714419062..1f09977b37b 100644--- a/front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts+++ b/front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts@@ -15,18 +15,25 @@ export const useSelectableList = (props?: UseSelectableListProps) => {props?.selectableListId,);- const { selectableItemIdsState, isSelectedItemIdSelector } =- useSelectableListScopedStates({- selectableListScopeId: scopeId,- itemId: props?.itemId,- });+ const {+ selectableItemIdsState,+ isSelectedItemIdSelector,+ selectableListOnEnterState,+ } = useSelectableListScopedStates({+ selectableListScopeId: scopeId,+ itemId: props?.itemId,+ });const setSelectableItemIds = useSetRecoilState(selectableItemIdsState);+ const setSelectableListOnEnter = useSetRecoilState(+ selectableListOnEnterState,+ );const isSelectedItemId = useRecoilValue(isSelectedItemIdSelector);return {setSelectableItemIds,isSelectedItemId,+ setSelectableListOnEnter,selectableListId: scopeId,isSelectedItemIdSelector,};diff --git a/front/src/modules/ui/layout/selectable-list/states/selectableItemIdsScopedState.ts b/front/src/modules/ui/layout/selectable-list/states/selectableItemIdsScopedState.tsindex 861b9bee944..1e56312e992 100644--- a/front/src/modules/ui/layout/selectable-list/states/selectableItemIdsScopedState.ts+++ b/front/src/modules/ui/layout/selectable-list/states/selectableItemIdsScopedState.ts@@ -1,6 +1,6 @@import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState';-export const selectableItemIdsScopedState = createScopedState<string[]>({+export const selectableItemIdsScopedState = createScopedState<string[][]>({key: 'selectableItemIdsScopedState',- defaultValue: [],+ defaultValue: [[]],});diff --git a/front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterScopedState.ts b/front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterScopedState.tsnew file mode 100644index 00000000000..ef6752569a3--- /dev/null+++ b/front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterScopedState.ts@@ -0,0 +1,8 @@+import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState';++export const selectableListOnEnterScopedState = createScopedState<+ ((itemId: string) => void) | undefined+>({+ key: 'selectableListOnEnterScopedState',+ defaultValue: undefined,+});diff --git a/front/src/modules/ui/layout/selectable-list/utils/internal/getSelectableListScopedStates.ts b/front/src/modules/ui/layout/selectable-list/utils/internal/getSelectableListScopedStates.tsindex 8a04dcb1452..847485dc510 100644--- a/front/src/modules/ui/layout/selectable-list/utils/internal/getSelectableListScopedStates.ts+++ b/front/src/modules/ui/layout/selectable-list/utils/internal/getSelectableListScopedStates.ts@@ -1,4 +1,5 @@import { selectableItemIdsScopedState } from '@/ui/layout/selectable-list/states/selectableItemIdsScopedState';+import { selectableListOnEnterScopedState } from '@/ui/layout/selectable-list/states/selectableListOnEnterScopedState';import { selectedItemIdScopedState } from '@/ui/layout/selectable-list/states/selectedItemIdScopedState';import { isSelectedItemIdScopedFamilySelector } from '@/ui/layout/selectable-list/states/selectors/isSelectedItemIdScopedFamilySelector';import { getScopedState } from '@/ui/utilities/recoil-scope/utils/getScopedState';@@ -27,9 +28,15 @@ export const getSelectableListScopedStates = ({selectableListScopeId,);+ const selectableListOnEnterState = getScopedState(+ selectableListOnEnterScopedState,+ selectableListScopeId,+ );+return {isSelectedItemIdSelector,selectableItemIdsState,selectedItemIdState,+ selectableListOnEnterState,};};diff --git a/front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts b/front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.tsindex beaf9715c5c..d8dc4d370cc 100644--- a/front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts+++ b/front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts@@ -74,6 +74,7 @@ export const useSetHotkeyScope = () =>}scopesToSet.push(newHotkeyScope.scope);+ console.log(scopesToSet);set(internalHotkeysEnabledScopesState, scopesToSet);set(currentHotkeyScopeState, newHotkeyScope);},diff --git a/front/src/utils/array/array-to-chunks.ts b/front/src/utils/array/array-to-chunks.tsnew file mode 100644index 00000000000..a6f5985bc1b--- /dev/null+++ b/front/src/utils/array/array-to-chunks.ts@@ -0,0 +1,11 @@+// split an array into subarrays of a given size+export const arrayToChunks = <T>(array: T[], size: number) => {+ const arrayCopy = [...array];+ const results = [];++ while (arrayCopy.length) {+ results.push(arrayCopy.splice(0, size));+ }++ return results;+};