Skip to content

Commit

Permalink
#2124 - fix filteredOptionsChildren lying about length
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsnes authored and mimarz committed Feb 21, 2025
1 parent e46da93 commit 874ec28
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@floating-ui/react": "0.26.12",
"@navikt/aksel-icons": "^5.12.2",
"@radix-ui/react-slot": "^1.0.2",
"@tanstack/react-virtual": "^3.2.0"
"@tanstack/react-virtual": "^3.5.1"
},
"devDependencies": {
"copyfiles": "^2.4.1",
Expand Down
10 changes: 6 additions & 4 deletions packages/react/src/components/form/Combobox/useCombobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ export default function useCombobox({
const { filteredOptions, filteredOptionsChildren } = useMemo(() => {
const filteredOptions: string[] = [];

const filteredOptionsChildren = Object.keys(options).map(
(option, index) => {
const filteredOptionsChildren = Object.keys(options)
.map((option, index) => {
/* If we have a selected value in single mode and the input matches an option, return all children */
if (!multiple && Object.keys(selectedOptions).length === 1) {
filteredOptions.push(options[option].value);
Expand All @@ -163,8 +163,10 @@ export default function useCombobox({
filteredOptions.push(options[option].value);
return optionsChildren[index];
}
},
);

return;
})
.filter((child) => child);

return { filteredOptions, filteredOptionsChildren };
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2257,7 +2257,7 @@ __metadata:
"@floating-ui/react": "npm:0.26.12"
"@navikt/aksel-icons": "npm:^5.12.2"
"@radix-ui/react-slot": "npm:^1.0.2"
"@tanstack/react-virtual": "npm:^3.2.0"
"@tanstack/react-virtual": "npm:^3.5.1"
copyfiles: "npm:^2.4.1"
esno: "npm:^4.7.0"
rimraf: "npm:^5.0.5"
Expand Down Expand Up @@ -6077,22 +6077,22 @@ __metadata:
languageName: node
linkType: hard

"@tanstack/react-virtual@npm:^3.2.0":
version: 3.2.0
resolution: "@tanstack/react-virtual@npm:3.2.0"
"@tanstack/react-virtual@npm:^3.5.1":
version: 3.5.1
resolution: "@tanstack/react-virtual@npm:3.5.1"
dependencies:
"@tanstack/virtual-core": "npm:3.2.0"
"@tanstack/virtual-core": "npm:3.5.1"
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
checksum: 10/09bf6db0f3dbfa2245c7d78ed425bb7c0e169cbe5024cc6bfc53005505a472b36a0b5506d6fa4b8a47c07296c5982b1ac49acd4f32c48547aef7556f9ed2ed1d
checksum: 10/11c8e9e2391fa0c947848a720b7dccccb1e35a78ac3169d1c34629bbec4ec713eed78d4c17a3e540e01386ee25b600a53254357597ae91a5fe35c7436651e975
languageName: node
linkType: hard

"@tanstack/virtual-core@npm:3.2.0":
version: 3.2.0
resolution: "@tanstack/virtual-core@npm:3.2.0"
checksum: 10/cf3ef6a2f3fa8ec4b155926da32508df45dadf268b365f206a171d011d6c728ddc9a7ea074575145266ccbdf445352ee9c9278bc1f55c3f96ad69ade7964b936
"@tanstack/virtual-core@npm:3.5.1":
version: 3.5.1
resolution: "@tanstack/virtual-core@npm:3.5.1"
checksum: 10/611ea09d37cf9183a51d2dfce401c3802b0d91f014e9bbaf32a6220ec7301b873b308130b795d935c0f5b73a43fd8358274915885da692d3e991eeeab6f8711b
languageName: node
linkType: hard

Expand Down

0 comments on commit 874ec28

Please sign in to comment.