Skip to content

Commit

Permalink
Dropdown widget with multiple values: Preserve order of selected item…
Browse files Browse the repository at this point in the history
…s when displaying configuration (#41)
  • Loading branch information
stefanseifert authored Aug 23, 2024
1 parent 4c38183 commit 212159b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
}

Expand Down
6 changes: 6 additions & 0 deletions changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<body>

<release version="1.16.4" date="not released">
<action type="fix" dev="sseifert" issue="40">
Dropdown widget with multiple values: Preserve order of selected items when displaying configuration.
</action>
</release>

<release version="1.16.2" date="2024-07-18">
<action type="fix" dev="sseifert" issue="37">
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).
Expand Down

0 comments on commit 212159b

Please sign in to comment.