Skip to content

Support directory uploads without multiple - #1338

Open
feritcemkahraman wants to merge 1 commit into
testing-library:mainfrom
feritcemkahraman:fix/directory-upload
Open

feritcemkahraman wants to merge 1 commit into
testing-library:mainfrom
feritcemkahraman:fix/directory-upload

Conversation

@feritcemkahraman

@feritcemkahraman feritcemkahraman commented Nov 2, 2026 •

Copy link
Copy Markdown

What

Allow upload to retain all files when a file input selects a directory via webkitdirectory, even if multiple is absent. Fixes #1292.

Why

A single selected directory can contain multiple files. Previously the upload helper truncated that selection to the first file.

How

Treat a directory input as a multi-file selection; keep the existing single-file limit for ordinary inputs. Check both the property and the attribute because jsdom may not reflect the non-standard property.

Checklist

  • Documentation: no public API changes.
  • Tests: upload suite passed (20 tests, 4 snapshots); TypeScript validation and ESLint for the changed files passed. The directory-attribute regression failed before the change.
  • Ready to be merged

AI assistance: Codex assisted with the implementation and tests.

Browser verification

In Brave on Windows, we manually selected a directory using the native picker on an input with webkitdirectory and without multiple. The browser returned five files. Passing those files to userEvent.upload on a second input with the same attributes retained all five, with matching file names and webkitRelativePath values. The selected directory had no nested folders.

@snowystinger

Copy link
Copy Markdown
Contributor

No real-browser directory picker was exercised.

Please run this and report back

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

upload() should support 'webkitdirectory' without 'multiple' being set

2 participants