Skip to content

Commit 1018671

Browse files
committed
Optimizations
1 parent ffe073a commit 1018671

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
@@ -111,11 +111,12 @@ export class UmbCompositionPickerModalElement extends UmbModalBaseElement<
111111

112112
if (!data) return;
113113

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

121122
#onSelectionAdd(unique: string) {

0 commit comments

Comments
 (0)