Skip to content

Commit

Permalink
fix(collection): fix collection sort function using by copying method (
Browse files Browse the repository at this point in the history
…#1434)

* fix(collection): collection sort by copying sort method

* chore: add changeset
  • Loading branch information
erm1116 committed Apr 19, 2024
1 parent 67f5faa commit ed0ee38
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/clean-clouds-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zag-js/collection": patch
---

Fix issue where value is unintentionally sorted when highlighting item in the combobox and the select machine
2 changes: 1 addition & 1 deletion packages/utilities/collection/src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class Collection<T extends CollectionItem = CollectionItem> {
* Sort the values based on their index
*/
sort = (values: string[]): string[] => {
return values.sort(this.sortFn)
return values.toSorted(this.sortFn)
}

/**
Expand Down

0 comments on commit ed0ee38

Please sign in to comment.