Repository navigation
feat(file-upload): add a file picker and dropzone - #934
urstruelysv wants to merge 7 commits into
Conversation
|
@urstruelysv is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi, thanks for opening #923. I built this to close it. Why it’s built this way Base UI has no file upload primitive, so the selection logic lives in a Three behaviours I chose. Please push back if any is wrong.
Dropzone click. Right now, only the trigger button opens the picker. Would you prefer the whole dropzone to open it too? Where I’d like your eyes The hook is the part I’d most like feedback on. It keeps the native file input, the Field error, and the accepted list in sync, and that’s where I’d expect edge cases. Verification
Firefox, Safari, and screen-reader behaviour remain untested. I used AI tools (Codex and Claude) to help write and review this. I’m happy to walk through any part of the code or the checks. I’ll respond to review comments the same day. If it’s easier to split the hook and the component into two PRs, I can do that. |
|
Safari keyboard demo · 90 seconds, silent file-upload-safari-silent.mp4Skip to 0:25 for the fourth-file rejection, 0:55 for focus after removal, 1:10 for the submitted filenames, or 1:20 for Reset. I tested the Supporting documents example on localhost at
|
|
Thanks a lot for this, @urstruelysv. File upload is out of scope for coss ui right now, so we're closing it for now. It's about scope, not the quality of your work. |
|
Thanks for the clear answer, understood on scope. One thing I noticed while reading the repo: about 14 components animate with no prefers-reduced-motion handling (accordion, collapsible, popover, tooltip, sheet, drawer, sidebar and others), while dialog, tabs and toast have it since #864. Would you take a small PR for that, say 4 or 5 components at a time? If you'd rather not, no problem. |
Fixes #923.
Summary
Apps can use the same coss field for browsing or dropping files, showing rejections, and submitting accepted attachments through a native form.
FileUpload,FileUploadDropzone,FileUploadTrigger,FileUploadList, andFileUploadItem. The trigger is a keyboard-accessible button. The list shows file names and sizes, image previews, removal, and optional progress supplied by the app.File[]values, nativeFormData, and form reset. The picker is separate from the form input so reopening or canceling it preserves the committed files. UseField validationMode="onChange"for immediate rejection messages.Try it
Open the Native forms example in the File Upload docs. Drop four small PDFs. Three should appear and the extra file should produce an error that blocks submission. Remove one accepted file and submit. The output should name only the remaining files. Reset should clear the list and output.
Verification
bun run testpassed all 93 tests, including 37 File Upload tests. The regressions cover late-mounted form reset and both rapid replacement and recovery when application and file rejections overlap.apps/uiproduction build passed with Webpack.With overlapping debounced errors, the old rejection can briefly remain visible after the application accepts a replacement, until Field refreshes. The Chromium checks used scripted file selection. Firefox, WebKit, the OS picker, and screen readers still need manual verification. The full monorepo Turbopack build was not verified locally.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.