From d1e9841e86a30df7c8625e9e6c967a5b90c601f1 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 14 Aug 2019 22:44:54 +0200 Subject: [PATCH] luci-base: ui.js: do not forcibly sort synamic list items Ref: https://forum.openwrt.org/t/cannot-save-certain-fields/42738/2 Signed-off-by: Jo-Philipp Wich --- modules/luci-base/htdocs/luci-static/resources/ui.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index 29233dec02..11886b91fe 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -1199,7 +1199,7 @@ var UIDynamicList = UIElement.extend({ 'name': this.options.name, 'value': value })]); - dl.querySelectorAll('.item, .add-item').forEach(function(item) { + dl.querySelectorAll('.item').forEach(function(item) { if (exists) return; @@ -1210,10 +1210,13 @@ var UIDynamicList = UIElement.extend({ if (hidden && hidden.value === value) exists = true; - else if (!hidden || hidden.value >= value) - exists = !!item.parentNode.insertBefore(new_item, item); }); + if (!exists) { + var ai = dl.querySelector('.add-item'); + ai.parentNode.insertBefore(new_item, ai); + } + dl.dispatchEvent(new CustomEvent('cbi-dynlist-change', { bubbles: true, detail: { -- 2.30.2