Trigger image upload from keyboard (#891) (#893)

* Adding tabindex to ImageUpload div wrapper in order to make it selectable
* Adding keyboard event handler to listen to Enter key stroke and trigger file upload selection

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
This commit is contained in:
JP Melanson 2024-03-01 19:42:47 -05:00 committed by GitHub
parent aa7c233177
commit fb1281dfd2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -229,7 +229,11 @@ export const ImageUpload = forwardRef(({ children, className, onSelect, onUpload
}
}}
/>
<div className={className} onClick={() => ref.current?.click()} style={{ cursor: 'pointer' }}>
<div
className={className} onClick={() => ref.current?.click()} style={{ cursor: 'pointer' }} tabindex={0} onKeyDown={(e) => {
if (e.key === 'Enter') { ref.current?.click() }
}}
>
{children}
</div>
</>