Skip to content

Commit

Permalink
Fix Combo Box Next onChange using stale values (#2697)
Browse files Browse the repository at this point in the history
Co-authored-by: Josh Wooding <[email protected]>
  • Loading branch information
el-dav and joshwooding authored Nov 10, 2023
1 parent 6a0dff7 commit c5aede9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-queens-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@salt-ds/lab": patch
---

Fix Combo Box Next `onChange` using stale values
4 changes: 2 additions & 2 deletions packages/lab/src/combo-box-next/ComboBoxNext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const ComboBoxNext = forwardRef(function ComboBoxNext<T>(
const getFilteredSource = () => {
if (!source) return null;
if (selectedItem && inputValue === selectedItem) return source;
return itemFilter && itemFilter(source, inputValue);
return itemFilter?.(source, inputValue);
};
const filteredSource = getFilteredSource();

Expand All @@ -214,7 +214,7 @@ export const ComboBoxNext = forwardRef(function ComboBoxNext<T>(
setHighlightedItem(filteredSource[0] as unknown as string);
}
}
onInputChange?.(event, { value: inputValue ?? "" });
onInputChange?.(event, { value: value ?? "" });
};

const adornment = open ? (
Expand Down

1 comment on commit c5aede9

@vercel
Copy link

@vercel vercel bot commented on c5aede9 Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.