luci-base: keep not yet rendered clone elements
authorChristian Korber <redacted>
Fri, 22 May 2026 10:00:27 +0000 (12:00 +0200)
committerPaul Donald <redacted>
Mon, 25 May 2026 08:35:28 +0000 (11:35 +0300)
`handleClone` triggers `checkDepends` and also `parse` on `this.map.save` which
in turn also removes not yet rendered elements like clones.

This is not wanted and therefore guarded against.

Signed-off-by: Christian Korber <redacted>
modules/luci-base/htdocs/luci-static/resources/form.js

index 54fca6930d21edd95ecf4f6c8cb7f859cdb2e479..7e5c4a256970c5922f59e582591fa9613f531292 100644 (file)
@@ -1309,6 +1309,12 @@ const CBIAbstractSection = CBIAbstractElement.extend(/** @lends LuCI.form.Abstra
                const sids = this.cfgsections();
 
                for (let i = 0, sid = sids[0]; (sid = sids[i]) != null; i++) {
+                       /*
+                        * do not remove elements that are not rendered yet
+                        */
+                       if (!this.map.findElement('data-section-id', sid))
+                               continue;
+
                        for (let j = 0, o = this.children[0]; (o = this.children[j]) != null; j++) {
                                let isActive = o.isActive(sid);
                                const isSatisfied = o.checkDepends(sid);
@@ -2155,7 +2161,11 @@ const CBIAbstractValue = CBIAbstractElement.extend(/** @lends LuCI.form.Abstract
                                }
                        }
                        else if (this.forcewrite || !isEqual(cval, fval)) {
-                               return Promise.resolve(this.write(section_id, fval));
+                               /*
+                                * do not remove elements that are not rendered yet
+                                */
+                               if (this.map.findElement('data-field', this.cbid(section_id)) != null)
+                                       return Promise.resolve(this.write(section_id, fval));
                        }
                }
                else if (!this.retain) {
git clone https://git.99rst.org/PROJECT