Skip to content

Commit dadfce9

Browse files
committed
fix(ComboBox): support for legacy field * 7
1 parent 03101e3 commit dadfce9

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

src/components/fields/ComboBox/ComboBox.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -331,23 +331,13 @@ export const ComboBox = forwardRef(function ComboBox<T extends object>(
331331
let onKeyPress = useEvent((e: KeyboardEvent) => {
332332
if (e.key === 'Enter') {
333333
if (!props.allowsCustomValue && state.isOpen) {
334-
const inputValue = inputRef?.current?.value;
334+
const option = [...state.collection][0]?.key;
335335

336-
if (inputValue === '') {
337-
state.close();
338-
props.onSelectionChange?.(null);
336+
if (option && selectedKey !== option) {
337+
props.onSelectionChange?.(option);
339338

340339
e.stopPropagation();
341340
e.preventDefault();
342-
} else {
343-
const option = [...state.collection][0]?.key;
344-
345-
if (option && selectedKey !== option) {
346-
props.onSelectionChange?.(option);
347-
348-
e.stopPropagation();
349-
e.preventDefault();
350-
}
351341
}
352342
// If a custom value is allowed, we need to check if the input value is in the collection.
353343
} else if (props.allowsCustomValue) {

0 commit comments

Comments
 (0)