luci-base: ui.js: resolve parent ul early in UIDropdown.toggleItem()
authorJo-Philipp Wich <jo@mein.io>
Fri, 19 Feb 2021 09:39:00 +0000 (10:39 +0100)
committerJo-Philipp Wich <jo@mein.io>
Fri, 19 Feb 2021 10:32:25 +0000 (11:32 +0100)
The parent node of the current li might be null after collapsing the
dropdown, so resolve the parent ul early to avoid passing null to
subsequent calls.

Fixes clearing custom input values in DynamicList dropdowns.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit b8d2bcd432ab23a883de1dd4fbce29f9751a6e84)

modules/luci-base/htdocs/luci-static/resources/ui.js

index 5d6b2e43f71b59bb868d516c65ff55fa40d39d45..95419c4991dd359b8ea961329b503875531128a9 100644 (file)
@@ -1306,6 +1306,8 @@ var UIDropdown = UIElement.extend(/** @lends LuCI.ui.Dropdown.prototype */ {
 
        /** @private */
        toggleItem: function(sb, li, force_state) {
+               var ul = li.parentNode;
+
                if (li.hasAttribute('unselectable'))
                        return;
 
@@ -1382,7 +1384,7 @@ var UIDropdown = UIElement.extend(/** @lends LuCI.ui.Dropdown.prototype */ {
                        this.closeDropdown(sb, true);
                }
 
-               this.saveValues(sb, li.parentNode);
+               this.saveValues(sb, ul);
        },
 
        /** @private */