FIX: when switching reply type update options

FIX: when switching reply type update options

Previously we were not correctly updating reply types leading to inconsistent behavior when using drop down in composer (for reply type)

diff --git a/app/assets/javascripts/select-kit/components/composer-actions.js b/app/assets/javascripts/select-kit/components/composer-actions.js
index 773c2b1..720dddd 100644
--- a/app/assets/javascripts/select-kit/components/composer-actions.js
+++ b/app/assets/javascripts/select-kit/components/composer-actions.js
@@ -20,6 +20,7 @@ export function _clearSnapshots() {
 }
 
 export default DropdownSelectBoxComponent.extend({
+  _seq: 0,
   pluginApiIdentifiers: ["composer-actions"],
   classNames: ["composer-actions"],
 
@@ -29,6 +30,10 @@ export default DropdownSelectBoxComponent.extend({
     showFullTitle: false
   },
 
+  contentChanged() {
+    this.set("_seq", this._seq + 1);
+  },
+
   didReceiveAttrs() {
     this._super(...arguments);
 
@@ -40,6 +45,7 @@ export default DropdownSelectBoxComponent.extend({
     ) {
       _topicSnapshot = this.get("composerModel.topic");
       _postSnapshot = this.get("composerModel.post");
+      this.contentChanged();
     }
 
     // if we hit reply on a different post we want to change postSnapshot
@@ -48,6 +54,7 @@ export default DropdownSelectBoxComponent.extend({
       (!_postSnapshot || this.get("composerModel.post.id") !== _postSnapshot.id)
     ) {
       _postSnapshot = this.get("composerModel.post");
+      this.contentChanged();
     }
 
     if (isEmpty(this.content)) {
@@ -59,7 +66,7 @@ export default DropdownSelectBoxComponent.extend({
     return {};
   },
 
-  content: computed(function() {
+  content: computed("_seq", function() {
     let items = [];
 
     if (
@@ -304,6 +311,7 @@ export default DropdownSelectBoxComponent.extend({
           ),
           this.composerModel
         );
+        this.contentChanged();
       } else {
         // eslint-disable-next-line no-console
         console.error(`No method '${action}' found`);

GitHub sha: fcc5ef96

1 Like

@jjaffeux nor 100% sure if this is the cleanest way , feel free to refactor

1 Like

At the very least we shouldn’t use underscores for variables that are used in computed properties. In the rest of our codebase _seq implies that you can avoid get/set on it.