Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit c912bfa

Browse files
Brian OchanTigge
authored andcommitted
feat(droppable): tab and select file with enter key
- Add ability to tab into droppable. - Add ability to select file using the enter key.
1 parent 5b060bc commit c912bfa

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/core/src/Droppable/__snapshots__/index.test.tsx.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ exports[`Droppable Droppable 1`] = `
133133
onDragLeave={[Function]}
134134
onDragOver={[Function]}
135135
onDrop={[Function]}
136+
onKeyUp={[Function]}
137+
tabIndex={0}
136138
>
137139
<span
138140
className="c3 c4"
@@ -325,6 +327,8 @@ exports[`Droppable Droppable 2`] = `
325327
onDragLeave={[Function]}
326328
onDragOver={[Function]}
327329
onDrop={[Function]}
330+
onKeyUp={[Function]}
331+
tabIndex={0}
328332
>
329333
<span
330334
className="c3 c4"

packages/core/src/Droppable/index.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ export const Droppable: React.FC<DroppableProps> = ({
139139
[handleFile, onChange]
140140
)
141141

142+
const handleKeyUp = useCallback<React.KeyboardEventHandler<BaseElement>>(
143+
e => {
144+
switch (e.key) {
145+
case 'Enter': {
146+
handleLinkClick()
147+
break
148+
}
149+
}
150+
},
151+
[handleLinkClick]
152+
)
153+
142154
const hasSelectedFile = selectedFileName !== undefined
143155

144156
return (
@@ -151,6 +163,8 @@ export const Droppable: React.FC<DroppableProps> = ({
151163
onDrop={handleDragAndDrop}
152164
onClick={handleLinkClick}
153165
className={className}
166+
tabIndex={0}
167+
onKeyUp={handleKeyUp}
154168
>
155169
<DroppableIcon icon={DropIcon} />
156170
<DroppableInputFile

0 commit comments

Comments
 (0)