From 212159b4b3a5ccc9c16008f859bc0c49b96e9f69 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 23 Aug 2024 08:56:10 +0200 Subject: [PATCH] Dropdown widget with multiple values: Preserve order of selected items when displaying configuration (#41) --- .../js/widgets/property-dropdown.directive.js | 11 +++++++++-- changes.xml | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/bundle/src/main/webapp/app-root/clientlibs/io.wcm.caconfig.editor/js/widgets/property-dropdown.directive.js b/bundle/src/main/webapp/app-root/clientlibs/io.wcm.caconfig.editor/js/widgets/property-dropdown.directive.js index 5370c681..324f9033 100644 --- a/bundle/src/main/webapp/app-root/clientlibs/io.wcm.caconfig.editor/js/widgets/property-dropdown.directive.js +++ b/bundle/src/main/webapp/app-root/clientlibs/io.wcm.caconfig.editor/js/widgets/property-dropdown.directive.js @@ -186,9 +186,16 @@ */ function setValue(selectWidget, value) { var newValues = angular.isArray(value) ? value.map(String) : [String(value)]; - + // de-select all existing items selectWidget.items.getAll().forEach(function(item) { - item.selected = newValues.indexOf(item.value) > -1; + item.selected = false; + }); + // reselect items exactly in the order stored in the data + newValues.forEach(value => { + var matchingItem = selectWidget.items.getAll().find(item => item.value == value); + if (matchingItem) { + matchingItem.selected = true; + } }); } diff --git a/changes.xml b/changes.xml index 29ce16e2..7ca3bf13 100644 --- a/changes.xml +++ b/changes.xml @@ -23,6 +23,12 @@ xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd"> + + + Dropdown widget with multiple values: Preserve order of selected items when displaying configuration. + + + Prevent view reload when actual view parameters do not change (avoid issue e.g. with selecting item in pathbrowser first time when Unified Shell is active in AEMaaCS).