FIX: Hide full screen toggle button when textarea is disabled (#14638)

FIX: Hide full screen toggle button when textarea is disabled (#14638)

diff --git a/app/assets/javascripts/discourse/app/components/composer-editor.js b/app/assets/javascripts/discourse/app/components/composer-editor.js
index f8d5282..b6c3d34 100644
--- a/app/assets/javascripts/discourse/app/components/composer-editor.js
+++ b/app/assets/javascripts/discourse/app/components/composer-editor.js
@@ -124,11 +124,6 @@ export default Component.extend(ComposerUpload, {
     );
   },
 
-  @discourseComputed("composer.requiredCategoryMissing", "composer.replyLength")
-  disableTextarea(requiredCategoryMissing, replyLength) {
-    return requiredCategoryMissing && replyLength === 0;
-  },
-
   @observes("focusTarget")
   setFocus() {
     if (this.focusTarget === "editor") {
diff --git a/app/assets/javascripts/discourse/app/components/composer-toggles.js b/app/assets/javascripts/discourse/app/components/composer-toggles.js
index b60019c..50fd654 100644
--- a/app/assets/javascripts/discourse/app/components/composer-toggles.js
+++ b/app/assets/javascripts/discourse/app/components/composer-toggles.js
@@ -40,4 +40,12 @@ export default Component.extend({
       ? "discourse-compress"
       : "discourse-expand";
   },
+
+  @discourseComputed("disableTextarea")
+  showFullScreenButton(disableTextarea) {
+    if (this.site.mobileView) {
+      return false;
+    }
+    return !disableTextarea;
+  },
 });
diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.js
index 5fcbe09..7d4c810 100644
--- a/app/assets/javascripts/discourse/app/controllers/composer.js
+++ b/app/assets/javascripts/discourse/app/controllers/composer.js
@@ -302,6 +302,11 @@ export default Controller.extend({
     return defaultComposer;
   },
 
+  @discourseComputed("model.requiredCategoryMissing", "model.replyLength")
+  disableTextarea(requiredCategoryMissing, replyLength) {
+    return requiredCategoryMissing && replyLength === 0;
+  },
+
   @discourseComputed("model.composeState", "model.creatingTopic", "model.post")
   popupMenuOptions(composeState) {
     if (composeState === "open" || composeState === "fullscreen") {
diff --git a/app/assets/javascripts/discourse/app/templates/components/composer-toggles.hbs b/app/assets/javascripts/discourse/app/templates/components/composer-toggles.hbs
index 4964ed3..5e8a017 100644
--- a/app/assets/javascripts/discourse/app/templates/components/composer-toggles.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/composer-toggles.hbs
@@ -20,7 +20,7 @@
     tabindex=-1
   }}
 
-  {{#unless site.mobileView}}
+  {{#if showFullScreenButton}}
     {{d-button
       class="btn-flat toggle-fullscreen btn-mini-toggle"
       icon=fullscreenIcon
@@ -28,5 +28,5 @@
       title=fullscreenTitle
       tabindex=-1
     }}
-  {{/unless}}
+  {{/if}}
 </div>
diff --git a/app/assets/javascripts/discourse/app/templates/composer.hbs b/app/assets/javascripts/discourse/app/templates/composer.hbs
index 977de97..12b49f9 100644
--- a/app/assets/javascripts/discourse/app/templates/composer.hbs
+++ b/app/assets/javascripts/discourse/app/templates/composer.hbs
@@ -45,10 +45,12 @@
               </div>
             {{/unless}}
             {{composer-toggles
-              composeState=model.composeState showToolbar=showToolbar
+              composeState=model.composeState
+              showToolbar=showToolbar
               toggleComposer=(action "toggle")
               toggleToolbar=(action "toggleToolbar")
               toggleFullscreen=(action "fullscreenComposer")
+              disableTextarea=disableTextarea
             }}
           </div>
           {{#unless model.viewFullscreen}}
@@ -111,29 +113,31 @@
         </div>
 
         {{component composerComponent
-                          topic=topic
-                          composer=model
-                          lastValidatedAt=lastValidatedAt
-                          canWhisper=canWhisper
-                          storeToolbarState=(action "storeToolbarState")
-                          onPopupMenuAction=(action "onPopupMenuAction")
-                          showUploadModal=(route-action "showUploadSelector")
-                          popupMenuOptions=popupMenuOptions
-                          draftStatus=model.draftStatus
-                          isUploading=isUploading
-                          isProcessingUpload=isProcessingUpload
-                          allowUpload=allowUpload
-                          uploadIcon=uploadIcon
-                          isCancellable=isCancellable
-                          uploadProgress=uploadProgress
-                          groupsMentioned=(action "groupsMentioned")
-                          cannotSeeMention=(action "cannotSeeMention")
-                          importQuote=(action "importQuote")
-                          togglePreview=(action "togglePreview")
-                          processPreview=showPreview
-                          showToolbar=showToolbar
-                          afterRefresh=(action "afterRefresh")
-                          focusTarget=focusTarget}}
+          topic=topic
+          composer=model
+          lastValidatedAt=lastValidatedAt
+          canWhisper=canWhisper
+          storeToolbarState=(action "storeToolbarState")
+          onPopupMenuAction=(action "onPopupMenuAction")
+          showUploadModal=(route-action "showUploadSelector")
+          popupMenuOptions=popupMenuOptions
+          draftStatus=model.draftStatus
+          isUploading=isUploading
+          isProcessingUpload=isProcessingUpload
+          allowUpload=allowUpload
+          uploadIcon=uploadIcon
+          isCancellable=isCancellable
+          uploadProgress=uploadProgress
+          groupsMentioned=(action "groupsMentioned")
+          cannotSeeMention=(action "cannotSeeMention")
+          importQuote=(action "importQuote")
+          togglePreview=(action "togglePreview")
+          processPreview=showPreview
+          showToolbar=showToolbar
+          afterRefresh=(action "afterRefresh")
+          focusTarget=focusTarget
+          disableTextarea=disableTextarea
+        }}
 
         {{plugin-outlet name="composer-after-composer-editor" connectorTagName="" args=(hash model=model)}}
         <div class="submit-panel">
@@ -247,7 +251,8 @@
         {{/if}}
       </div>
 
-      {{composer-toggles composeState=model.composeState
+      {{composer-toggles
+        composeState=model.composeState
         toggleFullscreen=(action "openIfDraft")
         toggleComposer=(action "toggle")
         toggleToolbar=(action "toggleToolbar")
diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js
index 7d34f5f..be2d7b9 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-uncategorized-test.js
@@ -29,6 +29,11 @@ acceptance(
         "textarea is disabled"
       );
 
+      assert.ok(
+        !exists("button.toggle-fullscreen"),
+        "fullscreen button is not present"
+      );
+
       const categoryChooser = selectKit(".category-chooser");
 
       await categoryChooser.expand();
@@ -47,6 +52,11 @@ acceptance(
         !exists(".d-editor-textarea-wrapper.disabled"),
         "textarea is still enabled"
       );
+
+      assert.ok(
+        exists("button.toggle-fullscreen"),
+        "fullscreen button is present"
+      );
     });
   }
 );
@@ -91,6 +101,11 @@ acceptance(
         "textarea is enabled"
       );
 
+      assert.ok(
+        exists("button.toggle-fullscreen"),
+        "fullscreen button is present"
+      );
+
       await click("#reply-control button.create");
       assert.ok(
         exists(".category-input .popup-tip.bad"),
diff --git a/app/assets/stylesheets/common/d-editor.scss b/app/assets/stylesheets/common/d-editor.scss
index 80878e0..a93e7ae 100644

[... diff too long, it was truncated ...]

GitHub sha: 919a9a902a20f41700246e20effc21fe9f42c9c4

This commit appears in #14638 which was approved by eviltrout. It was merged by pmusaraj.