only sort if it has a value
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user