FIX: Couldn't modify a widget that wasn't in the registry

FIX: Couldn’t modify a widget that wasn’t in the registry

diff --git a/app/assets/javascripts/discourse/lib/plugin-api.js.es6 b/app/assets/javascripts/discourse/lib/plugin-api.js.es6
index 1fa2f44..19c2c5f 100644
--- a/app/assets/javascripts/discourse/lib/plugin-api.js.es6
+++ b/app/assets/javascripts/discourse/lib/plugin-api.js.es6
@@ -42,6 +42,7 @@ import { registerCustomPostMessageCallback as registerCustomPostMessageCallback1
 import Sharing from "discourse/lib/sharing";
 import { addComposerUploadHandler } from "discourse/components/composer-editor";
 import { addCategorySortCriteria } from "discourse/components/edit-category-settings";
+import { queryRegistry } from "discourse/widgets/widget";
 
 // If you add any methods to the API ensure you bump up this number
 const PLUGIN_API_VERSION = "0.8.31";
@@ -325,7 +326,9 @@ class PluginApi {
    * `‍``
    **/
   attachWidgetAction(widget, actionName, fn) {
-    const widgetClass = this.container.factoryFor(`widget:${widget}`).class;
+    const widgetClass =
+      queryRegistry(widget) ||
+      this.container.factoryFor(`widget:${widget}`).class;
     widgetClass.prototype[actionName] = fn;
   }

GitHub sha: 6fec4982

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there: