From 339919cfffda6a6c3065a612872fee7b83ee6be5 Mon Sep 17 00:00:00 2001 From: ajnart Date: Mon, 6 Jun 2022 17:39:18 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20keyboard=20navigation=20(kind?= =?UTF-8?q?=20of)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #165 --- src/components/AppShelf/AppShelf.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/AppShelf/AppShelf.tsx b/src/components/AppShelf/AppShelf.tsx index 21793972d..a6fa98fcb 100644 --- a/src/components/AppShelf/AppShelf.tsx +++ b/src/components/AppShelf/AppShelf.tsx @@ -4,11 +4,13 @@ import { closestCenter, DndContext, DragOverlay, + KeyboardSensor, MouseSensor, + TouchSensor, useSensor, useSensors, } from '@dnd-kit/core'; -import { arrayMove, SortableContext } from '@dnd-kit/sortable'; +import { arrayMove, SortableContext, sortableKeyboardCoordinates } from '@dnd-kit/sortable'; import { useConfig } from '../../tools/state'; import { SortableAppShelfItem, AppShelfItem } from './AppShelfItem'; @@ -19,6 +21,15 @@ const AppShelf = (props: any) => { const [activeId, setActiveId] = useState(null); const { config, setConfig } = useConfig(); const sensors = useSensors( + useSensor(TouchSensor, { + activationConstraint: { + delay: 250, + tolerance: 5, + }, + }), + useSensor(KeyboardSensor, { + coordinateGetter: sortableKeyboardCoordinates, + }), useSensor(MouseSensor, { // Require the mouse to move by 10 pixels before activating activationConstraint: {