Skip to content

Commit

Permalink
Merge pull request #2067 from umbraco/v14/bugfix/fix-array-state-sorting
Browse files Browse the repository at this point in the history
Fix: array state sorting
  • Loading branch information
nielslyngsoe authored Jul 2, 2024
2 parents 9bc24ee + 59169de commit 0c2d4e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/libs/observable-api/states/array-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down

0 comments on commit 0c2d4e2

Please sign in to comment.