Skip to content

Commit db17ec7

Browse files
feat(ui): use dropzone noKeyboard opt instead of manual listener to disable on spacebar
1 parent 6320d18 commit db17ec7

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

invokeai/frontend/web/src/common/components/ImageUploader.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useAppSelector } from 'app/store/storeHooks';
66
import { activeTabNameSelector } from 'features/ui/store/uiSelectors';
77
import type { AnimationProps } from 'framer-motion';
88
import { AnimatePresence, motion } from 'framer-motion';
9-
import type { KeyboardEvent, PropsWithChildren } from 'react';
9+
import type { PropsWithChildren } from 'react';
1010
import { memo, useCallback, useEffect, useState } from 'react';
1111
import type { Accept, FileRejection } from 'react-dropzone';
1212
import { useDropzone } from 'react-dropzone';
@@ -118,6 +118,7 @@ const ImageUploader = (props: PropsWithChildren) => {
118118
onDrop,
119119
onDragOver,
120120
multiple: false,
121+
noKeyboard: true,
121122
});
122123

123124
useEffect(() => {
@@ -143,15 +144,8 @@ const ImageUploader = (props: PropsWithChildren) => {
143144
};
144145
}, [inputRef]);
145146

146-
const handleKeyDown = useCallback((e: KeyboardEvent) => {
147-
// Bail out if user hits spacebar - do not open the uploader
148-
if (e.key === ' ') {
149-
return;
150-
}
151-
}, []);
152-
153147
return (
154-
<Box {...getRootProps(dropzoneRootProps)} onKeyDown={handleKeyDown}>
148+
<Box {...getRootProps(dropzoneRootProps)}>
155149
<input {...getInputProps()} />
156150
{props.children}
157151
<AnimatePresence>

0 commit comments

Comments
 (0)