fix(chat): keep the file input in the layout so the picker opens
This commit is contained in:
@@ -18,7 +18,15 @@ Future<List<ChatPickedFile>?> _selectFiles() {
|
|||||||
final input = web.HTMLInputElement()
|
final input = web.HTMLInputElement()
|
||||||
..type = 'file'
|
..type = 'file'
|
||||||
..multiple = true;
|
..multiple = true;
|
||||||
input.style.display = 'none';
|
// Keep the input in the layout but out of sight: a display:none file input
|
||||||
|
// is refused by some browsers when click() runs outside the picker gesture.
|
||||||
|
input.style
|
||||||
|
..position = 'fixed'
|
||||||
|
..left = '-10000px'
|
||||||
|
..top = '0'
|
||||||
|
..width = '1px'
|
||||||
|
..height = '1px'
|
||||||
|
..opacity = '0';
|
||||||
|
|
||||||
final completer = Completer<List<ChatPickedFile>?>();
|
final completer = Completer<List<ChatPickedFile>?>();
|
||||||
|
|
||||||
@@ -56,12 +64,18 @@ Future<List<ChatPickedFile>?> _selectFiles() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
input.addEventListener('change', ((web.Event _) {
|
input.addEventListener(
|
||||||
unawaited(readSelection());
|
'change',
|
||||||
}).toJS);
|
((web.Event _) {
|
||||||
input.addEventListener('cancel', ((web.Event _) {
|
unawaited(readSelection());
|
||||||
finish(null);
|
}).toJS,
|
||||||
}).toJS);
|
);
|
||||||
|
input.addEventListener(
|
||||||
|
'cancel',
|
||||||
|
((web.Event _) {
|
||||||
|
finish(null);
|
||||||
|
}).toJS,
|
||||||
|
);
|
||||||
|
|
||||||
final body = web.document.body;
|
final body = web.document.body;
|
||||||
if (body == null) return Future.value(null);
|
if (body == null) return Future.value(null);
|
||||||
|
|||||||
Reference in New Issue
Block a user