Notice this example still only support single group of Sorter.
-
-
+
+
`;
diff --git a/src/Umbraco.Web.UI.Client/examples/sorter-with-nested-containers/sorter-group.ts b/src/Umbraco.Web.UI.Client/examples/sorter-with-nested-containers/sorter-group.ts
index 34fb05f6a4..85688f727d 100644
--- a/src/Umbraco.Web.UI.Client/examples/sorter-with-nested-containers/sorter-group.ts
+++ b/src/Umbraco.Web.UI.Client/examples/sorter-with-nested-containers/sorter-group.ts
@@ -13,15 +13,25 @@ export type ModelEntryType = {
@customElement('example-sorter-group')
export class ExampleSorterGroup extends UmbElementMixin(LitElement) {
+ @property({ type: Array, attribute: false })
+ public get initialItems(): ModelEntryType[] {
+ return this.items;
+ }
+ public set initialItems(value: ModelEntryType[]) {
+ // Only want to set the model initially, cause any re-render should not set this again.
+ if (this._items !== undefined) return;
+ this.items = value;
+ }
+
@property({ type: Array, attribute: false })
public get items(): ModelEntryType[] {
return this._items ?? [];
}
public set items(value: ModelEntryType[]) {
- // Only want to set the model initially, cause any re-render should not set this again.
- if (this._items !== undefined) return;
+ const oldValue = this._items;
this._items = value;
this.#sorter.setModel(this._items);
+ this.requestUpdate('items', oldValue);
}
private _items?: ModelEntryType[];
@@ -43,7 +53,7 @@ export class ExampleSorterGroup extends UmbElementMixin(LitElement) {
});
removeItem = (item: ModelEntryType) => {
- this.items = this._items!.filter((r) => r.name !== item.name);
+ this.items = this.items.filter((r) => r.name !== item.name);
};
render() {
@@ -55,9 +65,7 @@ export class ExampleSorterGroup extends UmbElementMixin(LitElement) {
(item) =>
html`