Skip to content

Commit

Permalink
[image_picker] Remove input element after completion (#5654)
Browse files Browse the repository at this point in the history
This PR attempts to remove the input element added to the DOM after image selection is completed.

Fixes flutter/flutter#139442
  • Loading branch information
Amir-P authored Jan 5, 2024
1 parent e8fb05f commit 15115f3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ Twin Sun, LLC <google-contrib@twinsunsolutions.com>
Amir Panahandeh <amirpanahandeh@gmail.com>
Daniele Cambi <dancam.dev@gmail.com>
Michele Benedetti <michelebenx98@gmail.com>
Taskulu LDA <contributions@taskulu.com>
3 changes: 2 additions & 1 deletion packages/image_picker/image_picker_for_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## NEXT
## 3.0.2

* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.
* Removes input element after completion

## 3.0.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ void main() {
source: ImageSource.camera,
);

expect(html.querySelector('flt-image-picker-inputs')?.children.isEmpty,
isFalse);

// Mock the browser behavior of selecting a file...
mockInput.dispatchEvent(html.Event('change'));

Expand All @@ -68,6 +71,8 @@ void main() {
completion(
DateTime.fromMillisecondsSinceEpoch(textFile.lastModified!),
));
expect(html.querySelector('flt-image-picker-inputs')?.children.isEmpty,
isTrue);
});

testWidgets('getMultiImageWithOptions can select multiple files', (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class ImagePickerPlugin extends ImagePickerPlatform {
) as html.FileUploadInputElement;
_injectAndActivate(input);

return _getSelectedXFiles(input);
return _getSelectedXFiles(input).whenComplete(input.remove);
}

// Deprecated methods follow...
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/image_picker_for_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: image_picker_for_web
description: Web platform implementation of image_picker
repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_for_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
version: 3.0.1
version: 3.0.2

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down

0 comments on commit 15115f3

Please sign in to comment.