From 0c5816bb08d159278fa33274c4f4cfd0cc1cd06a Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 29 Oct 2026 19:58:51 +0000 Subject: [PATCH] fix(chat): keep the file input in the layout so the picker opens --- .../domain/chat_attachment_picker_web.dart | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/app/lib/features/chat/domain/chat_attachment_picker_web.dart b/app/lib/features/chat/domain/chat_attachment_picker_web.dart index 6b9ae40c..b15260ec 100644 --- a/app/lib/features/chat/domain/chat_attachment_picker_web.dart +++ b/app/lib/features/chat/domain/chat_attachment_picker_web.dart @@ -18,7 +18,15 @@ Future?> _selectFiles() { final input = web.HTMLInputElement() ..type = 'file' ..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?>(); @@ -56,12 +64,18 @@ Future?> _selectFiles() { } } - input.addEventListener('change', ((web.Event _) { - unawaited(readSelection()); - }).toJS); - input.addEventListener('cancel', ((web.Event _) { - finish(null); - }).toJS); + input.addEventListener( + 'change', + ((web.Event _) { + unawaited(readSelection()); + }).toJS, + ); + input.addEventListener( + 'cancel', + ((web.Event _) { + finish(null); + }).toJS, + ); final body = web.document.body; if (body == null) return Future.value(null);