Repository navigation
Fix web file input never being attached to the document - #2228
Merged
Merged
Conversation
children.add() on an HTMLCollection does not exist in package:web, so the call resolved to the dart:js_interop JSAny.add extension (the JS + operator) and silently did nothing. Neither the hidden file input nor its flt-file-picker-inputs container was ever inserted into the DOM. Chromium still fires change on a detached input, but WebKit does not, so on Safari the picker future hung or completed with null. The input is now inserted with appendChild and kept attached until the session completes. When the window regains focus before change arrives, a selection already present on the input is returned instead of being treated as a cancellation. Bumps file_picker_web to 4.0.1. Fixes #2222
The option lives on FilePickerWebOptions, exported by file_picker_web, not on the empty WebOptions class from the platform interface.
1 of 4 tasks
This was referenced Oct 5, 2026
navaronbracke
approved these changes
Oct 5, 2026
End the session in the attachment test so its window focus listener does not leak into later tests, and shorten the changelog entries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2222
Problem
On Safari (macOS and iOS) picking a file never returned the selection. The future either hung or completed with
null, while Chrome worked fine.The root cause is that the hidden
<input type="file">was never inserted into the DOM.HTMLCollectionhas noaddmethod inpackage:web, sotarget.children.add(uploadInput)resolved to thedart:js_interopJSAny.addextension (the JS+operator). It compiled without warnings and silently did nothing. The same applied to theflt-file-picker-inputscontainer onbody. Chromium still fireschangeon a detached file input, WebKit does not.Changes
appendChild, and keep the input attached until the picking session completes.changearrives, return a selection already present on the input instead of treating it as a cancellation.WebFileInputSessioncovering attachment, selection, focus cancellation, focus before change, and thecancelevent.file_picker_webto 4.0.1 with a changelog entry.file_pickerREADME, which pointed to a nonexistentWebOptions.cancelUploadOnWindowBlurinstead ofFilePickerWebOptions.Testing
flutter test --platform chromepasses infile_picker_web(11 tests) andflutter analyzeis clean. Still needs a manual check on Safari.