Skip to content

Commit 279279f

Browse files
committed
only sort if it has a value
1 parent c3b3ea9 commit 279279f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libs/observable-api/states/array-state.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ export class UmbArrayState<T> extends UmbDeepState<T[]> {
3535
*/
3636
sortBy(sortMethod?: (a: T, b: T) => number) {
3737
this.#sortMethod = sortMethod;
38-
super.setValue([...this.getValue()].sort(this.#sortMethod));
38+
const value = this.getValue();
39+
if(value) {
40+
super.setValue([...value].sort(this.#sortMethod));
41+
}
3942
return this;
4043
}
4144

0 commit comments

Comments
 (0)