Sort available composition folders (#19373)

* Sort available composition folders

* Optimizations
This commit is contained in:
Laura Neto
2025-05-29 09:08:55 +02:00
committed by GitHub
parent 1726180b06
commit c4be7842a7

View File

@@ -115,11 +115,12 @@ export class UmbCompositionPickerModalElement extends UmbModalBaseElement<
if (!data) return;
const folders = Array.from(new Set(data.map((c) => '/' + c.folderPath.join('/'))));
this._compatibleCompositions = folders.map((path) => ({
path,
compositions: data.filter((c) => '/' + c.folderPath.join('/') === path),
}));
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
const grouped = Object.groupBy(data, (item) => '/' + item.folderPath.join('/'));
this._compatibleCompositions = Object.keys(grouped)
.sort((a, b) => a.localeCompare(b))
.map((key) => ({ path: key, compositions: grouped[key] }));
}
#onSelectionAdd(unique: string) {