From: Jo-Philipp Wich Date: Sun, 28 Jul 2019 15:24:12 +0000 (+0200) Subject: luci-base: ui.js: mark widget optional if empty choice is present X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=360e9769d612d4aab388cae2ddb74794eb08240f;p=oweals%2Fluci.git luci-base: ui.js: mark widget optional if empty choice is present Fixes: #2943 Signed-off-by: Jo-Philipp Wich --- diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index f6a964fb1..fd413042f 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -223,6 +223,9 @@ var UISelect = UIElement.extend({ widget: 'select', orientation: 'horizontal' }, options); + + if (this.choices.hasOwnProperty('')) + this.options.optional = true; }, render: function() { @@ -243,7 +246,7 @@ var UISelect = UIElement.extend({ 'multiple': this.options.multiple ? '' : null })); - if (this.options.optional || this.choices.hasOwnProperty('')) + if (this.options.optional) frameEl.lastChild.appendChild(E('option', { 'value': '', 'selected': (this.values.length == 0 || this.values[0] == '') ? '' : null