Skip to content

Commit 29d3499

Browse files
authored
fix(ComboBox): outside-form behavior (#631)
1 parent 43617f4 commit 29d3499

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

.changeset/wicked-goats-speak.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
Fix ComboBox behavior outside the form.

src/components/fields/ComboBox/ComboBox.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,14 @@ export const ComboBox = forwardRef(function ComboBox<T extends object>(
329329

330330
// If input is not full and the user presses Enter, pick the first option.
331331
let onKeyPress = useEvent((e: KeyboardEvent) => {
332+
if (!props.onSelectionChange) {
333+
return;
334+
}
335+
332336
if (e.key === 'Enter') {
333337
if (!props.allowsCustomValue) {
334338
if (state.isOpen) {
335339
const option = [...state.collection][0]?.key;
336-
337340
if (option && selectedKey !== option) {
338341
props.onSelectionChange?.(option);
339342

0 commit comments

Comments
 (0)