Skip to content

Commit aeefcc6

Browse files
authored
fix: open section/unit with keyboard inside section/subsection page (#2209)
When selecting a unit/subsection inside a subsection/section with the keyboard, opening it in the sidebar by pressing enter was not working.
1 parent 4905f3b commit aeefcc6

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/generic/DraggableList/SortableItem.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { MouseEventHandler } from 'react';
1+
import React, { KeyboardEventHandler, MouseEventHandler } from 'react';
22
import { useSortable } from '@dnd-kit/sortable';
33
import { CSS } from '@dnd-kit/utilities';
44
import {
@@ -16,6 +16,7 @@ interface SortableItemProps {
1616
componentStyle?: {},
1717
isClickable?: boolean,
1818
onClick?: MouseEventHandler,
19+
onKeyDown?: KeyboardEventHandler,
1920
disabled?: boolean,
2021
cardClassName?: string,
2122
}
@@ -28,6 +29,7 @@ const SortableItem = ({
2829
children,
2930
isClickable,
3031
onClick,
32+
onKeyDown,
3133
disabled,
3234
cardClassName = '',
3335
}: SortableItemProps) => {
@@ -60,6 +62,7 @@ const SortableItem = ({
6062
<div
6163
ref={setNodeRef}
6264
onClick={onClick}
65+
onKeyDown={onKeyDown}
6366
>
6467
<Card
6568
style={style}

src/library-authoring/section-subsections/LibraryContainerChildren.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,13 @@ export const LibraryContainerChildren = ({ containerKey, readOnly }: LibraryCont
223223
borderRadius: '8px',
224224
borderLeft: '8px solid #E1DDDB',
225225
}}
226-
isClickable={!readOnly}
227-
onClick={(e) => !readOnly && handleChildClick(child, e.detail)}
226+
isClickable
227+
onClick={(e) => handleChildClick(child, e.detail)}
228+
onKeyDown={(e) => {
229+
if (e.key === 'Enter') {
230+
handleChildClick(child, 1);
231+
}
232+
}}
228233
disabled={readOnly || libReadOnly}
229234
cardClassName={sidebarItemInfo?.id === child.originalId ? 'selected' : undefined}
230235
actions={(

0 commit comments

Comments
 (0)