From f3273bd43ea1ea8bd9b83b88cf4ff40a8d0327f4 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Mon, 13 Sep 2021 09:16:03 +1000 Subject: [PATCH] FIX: Do not error mobile upload button if !allowUpload (#14317) allowUpload can be false for the composer if there are no allowed file extensions. This causes the _bindMobileUploadButton code to fail because the button does not get rendered in the template if !allowUpload. This commit changes composer-editor to only bind upload functionality if allowUpload. --- .../javascripts/discourse/app/components/composer-editor.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/composer-editor.js b/app/assets/javascripts/discourse/app/components/composer-editor.js index bc351f69270..0a625f4a1f6 100644 --- a/app/assets/javascripts/discourse/app/components/composer-editor.js +++ b/app/assets/javascripts/discourse/app/components/composer-editor.js @@ -237,8 +237,10 @@ export default Component.extend(ComposerUpload, { putCursorAtEnd(this.element.querySelector(".d-editor-input")); } - this._bindUploadTarget(); - this._bindMobileUploadButton(); + if (this.allowUpload) { + this._bindUploadTarget(); + this._bindMobileUploadButton(); + } this.appEvents.trigger("composer:will-open"); },