@thecb/components 6.0.0-beta.22 → 6.0.0-beta.25

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "6.0.0-beta.22",
3
+ "version": "6.0.0-beta.25",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -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 inputBox = useRef(null);
110
111
 
111
112
  if (optionsState !== options) {
112
113
  setOptionsState(options);
@@ -208,9 +209,11 @@ const Dropdown = ({
208
209
  if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
209
210
  // WAI-ARIA requires the selected option to receive focus
210
211
  selectedRef.current.focus();
212
+ inputBox.current.focus();
211
213
  } else if (isOpen && optionRefs.current[0].current) {
212
214
  // If no selected option, first option receives focus
213
215
  optionRefs.current[0].current.focus();
216
+ inputBox.current.focus();
214
217
  }
215
218
  clearTimeout(timer);
216
219
  setInputValue("");
@@ -232,6 +235,11 @@ const Dropdown = ({
232
235
 
233
236
  useEffect(() => {
234
237
  if (
238
+ /*
239
+ Either user has typed a value into input that matches a non-disabled option
240
+ or
241
+ user has autofilled or pasted into input a string matching a valid option
242
+ */
235
243
  (!isOpen || inputChangedByAutofill) &&
236
244
  filteredOptions[0] &&
237
245
  !disabledValues.includes(filteredOptions[0].value) &&
@@ -239,6 +247,9 @@ const Dropdown = ({
239
247
  ) {
240
248
  setInputChangedByAutofill(false);
241
249
  onSelect(filteredOptions[0].value);
250
+ if (isOpen) {
251
+ setTimeout(() => onClick(), 2000);
252
+ }
242
253
  }
243
254
  if (optionRefs.current[0].current) {
244
255
  optionRefs.current[0].current.focus();
@@ -305,6 +316,7 @@ const Dropdown = ({
305
316
  }}
306
317
  padding="12px"
307
318
  placeholder={getSelection()}
319
+ ref={inputBox}
308
320
  role="combobox"
309
321
  themeValues={themeValues}
310
322
  title={hasTitles ? getSelection() : null}