luci-base: Fix using isActive in widget-change notification. 4531/head
authorOldřich Jedlička <oldium.pro@gmail.com>
Tue, 20 Oct 2020 18:15:30 +0000 (20:15 +0200)
committerOldřich Jedlička <oldium.pro@gmail.com>
Fri, 30 Oct 2020 20:18:45 +0000 (21:18 +0100)
The `onchange` notification handler is called too early to be able to
evaluate other widget's `isActive()` status. Solve this by changing order
of event handling - first register/execute `map.checkDepends` and then
`onchange`.

Fixes: openwrt/luci#4516.
Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com>
modules/luci-base/htdocs/luci-static/resources/form.js

index 568a4abb6aa6761439e735db7f025c7718199197..1d705e3bf20b2a220f0072847122937c6630fca3 100644 (file)
@@ -3351,10 +3351,10 @@ var CBIValue = CBIAbstractValue.extend(/** @lends LuCI.form.Value.prototype */ {
                        optionEl.classList.add('hidden');
 
                optionEl.addEventListener('widget-change',
-                       L.bind(this.handleValueChange, this, section_id, {}));
+                       L.bind(this.map.checkDepends, this.map));
 
                optionEl.addEventListener('widget-change',
-                       L.bind(this.map.checkDepends, this.map));
+                       L.bind(this.handleValueChange, this, section_id, {}));
 
                dom.bindClassInstance(optionEl, this);