Skip to content

A platform for community discussion. Free, open, simple.

FIX: "Attach a file" unresponsive in chat on desktop Safari (#37179)

Régis Hanol9cbb0c3da39e
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer-dropdown.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-composer-dropdown.gjs
index c2cbecfaa6a..e3f869c4663 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-composer-dropdown.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-composer-dropdown.gjs
@@ -9,9 +9,13 @@ import { i18n } from "discourse-i18n";
export default class ChatComposerDropdown extends Component {
@action
- async onButtonClick(button, closeFn) {
- await closeFn();
-
+ onButtonClick(button, closeFn) {
+ // ⚠️ Do not use async/await here ⚠️
+ // Safari requires file input clicks to happen synchronously
+ // within the user gesture event chain. Using await breaks this
+ // chain and prevents the file picker from opening.
+ // See: https://webkit.org/blog/13862/the-user-activation-api/
+ closeFn();
button.action();
}