@thecb/components 6.0.0-beta.21 → 6.0.0-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +24 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +24 -12
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +12 -8
package/package.json
CHANGED
|
@@ -106,6 +106,7 @@ const Dropdown = ({
|
|
|
106
106
|
const [optionsChanged, setOptionsChanged] = useState(true);
|
|
107
107
|
const [selectedRef, setSelectedRef] = useState(undefined);
|
|
108
108
|
const [focusedRef, setFocusedRef] = useState(undefined);
|
|
109
|
+
const [inputChangedByAutofill, setInputChangedByAutofill] = useState(false);
|
|
109
110
|
|
|
110
111
|
if (optionsState !== options) {
|
|
111
112
|
setOptionsState(options);
|
|
@@ -231,12 +232,21 @@ const Dropdown = ({
|
|
|
231
232
|
|
|
232
233
|
useEffect(() => {
|
|
233
234
|
if (
|
|
234
|
-
|
|
235
|
+
/*
|
|
236
|
+
Either user has typed a value into input that matches a non-disabled option
|
|
237
|
+
or
|
|
238
|
+
user has autofilled or pasted into input a string matching a valid option
|
|
239
|
+
*/
|
|
240
|
+
(!isOpen || inputChangedByAutofill) &&
|
|
235
241
|
filteredOptions[0] &&
|
|
236
242
|
!disabledValues.includes(filteredOptions[0].value) &&
|
|
237
243
|
filteredOptions[0].text != placeholder
|
|
238
244
|
) {
|
|
245
|
+
setInputChangedByAutofill(false);
|
|
239
246
|
onSelect(filteredOptions[0].value);
|
|
247
|
+
if (isOpen) {
|
|
248
|
+
setTimeout(() => onClick(), 2000);
|
|
249
|
+
}
|
|
240
250
|
}
|
|
241
251
|
if (optionRefs.current[0].current) {
|
|
242
252
|
optionRefs.current[0].current.focus();
|
|
@@ -291,13 +301,6 @@ const Dropdown = ({
|
|
|
291
301
|
minHeight="48px"
|
|
292
302
|
minWidth="100%"
|
|
293
303
|
name={autocompleteValue}
|
|
294
|
-
onFocus={() => {
|
|
295
|
-
/*
|
|
296
|
-
if (!isOpen) {
|
|
297
|
-
onClick();
|
|
298
|
-
}
|
|
299
|
-
*/
|
|
300
|
-
}}
|
|
301
304
|
onChange={e => {
|
|
302
305
|
console.log("current input value onChange", inputValue);
|
|
303
306
|
console.log("input change event", e.target);
|
|
@@ -305,6 +308,7 @@ const Dropdown = ({
|
|
|
305
308
|
// support autofill and copy/paste
|
|
306
309
|
if (e.target.value !== inputValue) {
|
|
307
310
|
setInputValue(e.target.value);
|
|
311
|
+
setInputChangedByAutofill(true);
|
|
308
312
|
}
|
|
309
313
|
}}
|
|
310
314
|
padding="12px"
|