From 360e9769d612d4aab388cae2ddb74794eb08240f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 28 Jul 2019 17:24:12 +0200 Subject: [PATCH] luci-base: ui.js: mark widget optional if empty choice is present Fixes: #2943 Signed-off-by: Jo-Philipp Wich --- modules/luci-base/htdocs/luci-static/resources/ui.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index f6a964fb10..fd413042f9 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 -- 2.30.2