From 43e17f92e09208cf6f08600df6e5419730a4c787 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Tue, 9 Jun 2020 19:58:17 +0200 Subject: [PATCH] DEV: allows to call a widget function without re-rendering the widget (#10004) --- .../javascripts/discourse/app/widgets/widget.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/app/widgets/widget.js b/app/assets/javascripts/discourse/app/widgets/widget.js index 99220973c8e..378035ab7be 100644 --- a/app/assets/javascripts/discourse/app/widgets/widget.js +++ b/app/assets/javascripts/discourse/app/widgets/widget.js @@ -327,14 +327,21 @@ export default class Widget { }); } + callWidgetFunction(name, param) { + const widget = this._findAncestorWithProperty(name); + if (widget) { + return widget[name].call(widget, param); + } + } + sendWidgetAction(name, param) { return this.rerenderResult(() => { - const widget = this._findAncestorWithProperty(name); - if (widget) { - return widget[name].call(widget, param); - } + const widgetFunction = this.callWidgetFunction(name, param); - return this._sendComponentAction(name, param || this.findAncestorModel()); + return ( + widgetFunction || + this._sendComponentAction(name, param || this.findAncestorModel()) + ); }); }