Skip to content

Commit e6246bd

Browse files
authored
fix(ComboBox): input value inside form (#533)
1 parent c3e1ae2 commit e6246bd

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.changeset/brown-cooks-sin.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': minor
3+
---
4+
5+
Fix for Combobox input inside Form.

src/components/fields/ComboBox/ComboBox.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ReactElement,
66
RefObject,
77
useMemo,
8+
useState,
89
} from 'react';
910
import {
1011
useButton,
@@ -133,12 +134,17 @@ export const ComboBox = forwardRef(function ComboBox<T extends object>(
133134
props: CubeComboBoxProps<T>,
134135
ref: ForwardedRef<HTMLDivElement>,
135136
) {
137+
const [, rerender] = useState({});
138+
136139
props = useProviderProps(props);
137140
props = useFormProps(props);
138141
props = useFieldProps(props, {
139142
valuePropsMapper: ({ value, onChange }) => ({
140143
inputValue: value != null ? value : '',
141-
onInputChange: (val) => onChange(val, !props.allowsCustomValue),
144+
onInputChange: (val) => {
145+
onChange(val, !props.allowsCustomValue);
146+
rerender({});
147+
},
142148
onSelectionChange: onChange,
143149
}),
144150
});

0 commit comments

Comments
 (0)