From 9780bc01525128ee533f3ddb0d14ffe842477dde Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 16 May 2022 11:49:28 +0200 Subject: [PATCH] luci-base: form.js: reset parent maps on returning from nested section modal The nested section modal might have changed values also covered/displayed by the parent map, so ensure to reload all parent maps in the current modal view stack to ensure that no stale values are shown on return. Signed-off-by: Jo-Philipp Wich (cherry picked from commit 0c81e25faa9ff9cb6edec477d56145d70be87cf3) --- .../htdocs/luci-static/resources/form.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index 98d9342057..fc7ddb8a8a 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -2995,10 +2995,20 @@ var CBITableSection = CBITypedSection.extend(/** @lends LuCI.form.TableSection.p /** @private */ handleModalCancel: function(modalMap, ev) { - var prevNode = this.getPreviousModalMap(); + var prevNode = this.getPreviousModalMap(), + resetTasks = Promise.resolve(); if (prevNode) { - var heading = prevNode.parentNode.querySelector('h4'); + var heading = prevNode.parentNode.querySelector('h4'), + prevMap = dom.findClassInstance(prevNode); + + while (prevMap) { + resetTasks = resetTasks + .then(L.bind(prevMap.load, prevMap)) + .then(L.bind(prevMap.reset, prevMap)); + + prevMap = prevMap.parent; + } prevNode.classList.add('flash'); prevNode.classList.remove('hidden'); @@ -3015,7 +3025,7 @@ var CBITableSection = CBITypedSection.extend(/** @lends LuCI.form.TableSection.p ui.hideModal(); } - return Promise.resolve(); + return resetTasks; }, /** @private */ -- 2.30.2