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

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.21",
3
+ "version": "6.0.0-beta.22",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -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,11 +232,12 @@ const Dropdown = ({
231
232
 
232
233
  useEffect(() => {
233
234
  if (
234
- !isOpen &&
235
+ (!isOpen || inputChangedByAutofill) &&
235
236
  filteredOptions[0] &&
236
237
  !disabledValues.includes(filteredOptions[0].value) &&
237
238
  filteredOptions[0].text != placeholder
238
239
  ) {
240
+ setInputChangedByAutofill(false);
239
241
  onSelect(filteredOptions[0].value);
240
242
  }
241
243
  if (optionRefs.current[0].current) {
@@ -291,13 +293,6 @@ const Dropdown = ({
291
293
  minHeight="48px"
292
294
  minWidth="100%"
293
295
  name={autocompleteValue}
294
- onFocus={() => {
295
- /*
296
- if (!isOpen) {
297
- onClick();
298
- }
299
- */
300
- }}
301
296
  onChange={e => {
302
297
  console.log("current input value onChange", inputValue);
303
298
  console.log("input change event", e.target);
@@ -305,6 +300,7 @@ const Dropdown = ({
305
300
  // support autofill and copy/paste
306
301
  if (e.target.value !== inputValue) {
307
302
  setInputValue(e.target.value);
303
+ setInputChangedByAutofill(true);
308
304
  }
309
305
  }}
310
306
  padding="12px"