Merge pull request #2067 from umbraco/v14/bugfix/fix-array-state-sorting

Fix: array state sorting
This commit is contained in:
Niels Lyngsø
2024-07-02 10:18:06 +02:00
committed by GitHub
2 changed files with 6 additions and 3 deletions

View File

@@ -35,7 +35,10 @@ export class UmbArrayState<T> extends UmbDeepState<T[]> {
*/
sortBy(sortMethod?: (a: T, b: T) => number) {
this.#sortMethod = sortMethod;
super.setValue(this.getValue().sort(this.#sortMethod));
const value = this.getValue();
if(value) {
super.setValue([...value].sort(this.#sortMethod));
}
return this;
}
@@ -51,7 +54,7 @@ export class UmbArrayState<T> extends UmbDeepState<T[]> {
*/
override setValue(value: T[]) {
if (this.#sortMethod) {
super.setValue(value.sort(this.#sortMethod));
super.setValue([...value].sort(this.#sortMethod));
} else {
super.setValue(value);
}

View File

@@ -1,5 +1,5 @@
import { manifest as blockListSchemaManifest } from './Umbraco.BlockList.js';
import type { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry';
import { manifest as blockListSchemaManifest } from './Umbraco.BlockList.js';
export const UMB_BLOCK_LIST_PROPERTY_EDITOR_ALIAS = 'Umbraco.BlockList';