Skip to content

Commit a688b87

Browse files
committed
fix(forms): fix FormAutocomplete selecting the wrong item
1 parent d45adfd commit a688b87

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

demo/FormExamples.jsx

+4-14
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,10 @@ export function FormExamples() {
122122
<FormGroupAutocomplete
123123
name="autocompleteField3"
124124
label="Autocomplete with item template"
125-
options={[
126-
{
127-
value: 1,
128-
label: '1234',
129-
},
130-
{
131-
value: 2,
132-
label: '2345',
133-
},
134-
{
135-
value: 3,
136-
label: '3456',
137-
},
138-
]}
125+
options={Array.from({ length: 10 }).map((_, index) => ({
126+
value: index + 1,
127+
label: `${index + 1}${index + 2}${index + 3}${index + 4}`,
128+
}))}
139129
placeholder="Type some numbers"
140130
template={(option) => (
141131
<>

src/forms/FormAutocomplete.jsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ export function FormAutocomplete({
6060
}
6161
}}
6262
onBlur={() => {
63-
if (!value) {
64-
setSearchValue('');
65-
}
66-
6763
if (ignoreBlur) {
6864
searchInputRef.current.focus();
6965
} else {
@@ -110,9 +106,10 @@ export function FormAutocomplete({
110106
setTimeout(() => {
111107
setFocus(false);
112108
close();
113-
}, 100);
109+
}, 60);
114110
}}
115111
template={template}
112+
onClick={(e) => e.stopPropation()}
116113
onTouchStart={() => setIgnoreBlur(true)}
117114
onMouseEnter={() => setIgnoreBlur(true)}
118115
onMouseLeave={() => setIgnoreBlur(false)}

0 commit comments

Comments
 (0)