@thecb/components 6.0.0-beta.28 → 6.0.0-beta.29
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/package.json
CHANGED
|
@@ -107,6 +107,7 @@ const Dropdown = ({
|
|
|
107
107
|
const [selectedRef, setSelectedRef] = useState(undefined);
|
|
108
108
|
const [focusedRef, setFocusedRef] = useState(undefined);
|
|
109
109
|
const [inputChangedByAutofill, setInputChangedByAutofill] = useState(false);
|
|
110
|
+
const [focusedByClick, setFocusedByClick] = useState(false);
|
|
110
111
|
|
|
111
112
|
if (optionsState !== options) {
|
|
112
113
|
setOptionsState(options);
|
|
@@ -209,11 +210,13 @@ const Dropdown = ({
|
|
|
209
210
|
if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
|
|
210
211
|
// WAI-ARIA requires the selected option to receive focus
|
|
211
212
|
selectedRef.current.focus();
|
|
212
|
-
console.log("input box ref", inputRef, inputRef.current);
|
|
213
213
|
} else if (isOpen && optionRefs.current[0].current) {
|
|
214
214
|
// If no selected option, first option receives focus
|
|
215
215
|
optionRefs.current[0].current.focus();
|
|
216
|
-
|
|
216
|
+
}
|
|
217
|
+
if (isOpen && focusedByClick) {
|
|
218
|
+
inputRef.current.focus();
|
|
219
|
+
setFocusedByClick(false);
|
|
217
220
|
}
|
|
218
221
|
clearTimeout(timer);
|
|
219
222
|
setInputValue("");
|
|
@@ -266,6 +269,7 @@ const Dropdown = ({
|
|
|
266
269
|
minWidth="100%"
|
|
267
270
|
onClick={() => {
|
|
268
271
|
if (!isOpen) {
|
|
272
|
+
setFocusedByClick(true);
|
|
269
273
|
onClick();
|
|
270
274
|
}
|
|
271
275
|
}}
|