Skip to content

Commit c4be784

Browse files
authored
Sort available composition folders (#19373)
* Sort available composition folders * Optimizations
1 parent 1726180 commit c4be784

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Umbraco.Web.UI.Client/src/packages/content/content-type/modals/composition-picker/composition-picker-modal.element.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ export class UmbCompositionPickerModalElement extends UmbModalBaseElement<
115115

116116
if (!data) return;
117117

118-
const folders = Array.from(new Set(data.map((c) => '/' + c.folderPath.join('/'))));
119-
this._compatibleCompositions = folders.map((path) => ({
120-
path,
121-
compositions: data.filter((c) => '/' + c.folderPath.join('/') === path),
122-
}));
118+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
119+
// @ts-expect-error
120+
const grouped = Object.groupBy(data, (item) => '/' + item.folderPath.join('/'));
121+
this._compatibleCompositions = Object.keys(grouped)
122+
.sort((a, b) => a.localeCompare(b))
123+
.map((key) => ({ path: key, compositions: grouped[key] }));
123124
}
124125

125126
#onSelectionAdd(unique: string) {

0 commit comments

Comments
 (0)