@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.esm.js CHANGED
@@ -20738,6 +20738,11 @@ var Dropdown = function Dropdown(_ref8) {
20738
20738
  focusedRef = _useState12[0],
20739
20739
  setFocusedRef = _useState12[1];
20740
20740
 
20741
+ var _useState13 = useState(false),
20742
+ _useState14 = _slicedToArray(_useState13, 2),
20743
+ inputChangedByAutofill = _useState14[0],
20744
+ setInputChangedByAutofill = _useState14[1];
20745
+
20741
20746
  if (optionsState !== options) {
20742
20747
  setOptionsState(options);
20743
20748
  setOptionsChanged(true);
@@ -20748,10 +20753,10 @@ var Dropdown = function Dropdown(_ref8) {
20748
20753
  setOptionsChanged(false);
20749
20754
  }
20750
20755
 
20751
- var _useState13 = useState(null),
20752
- _useState14 = _slicedToArray(_useState13, 2),
20753
- timer = _useState14[0],
20754
- setTimer = _useState14[1];
20756
+ var _useState15 = useState(null),
20757
+ _useState16 = _slicedToArray(_useState15, 2),
20758
+ timer = _useState16[0],
20759
+ setTimer = _useState16[1];
20755
20760
 
20756
20761
  var optionRefs = useRef(_toConsumableArray(Array(options.length)).map(function () {
20757
20762
  return /*#__PURE__*/createRef();
@@ -20889,8 +20894,21 @@ var Dropdown = function Dropdown(_ref8) {
20889
20894
  }));
20890
20895
  }, [inputValue]);
20891
20896
  useEffect$1(function () {
20892
- if (!isOpen && filteredOptions[0] && !disabledValues.includes(filteredOptions[0].value) && filteredOptions[0].text != placeholder) {
20897
+ if (
20898
+ /*
20899
+ Either user has typed a value into input that matches a non-disabled option
20900
+ or
20901
+ user has autofilled or pasted into input a string matching a valid option
20902
+ */
20903
+ (!isOpen || inputChangedByAutofill) && filteredOptions[0] && !disabledValues.includes(filteredOptions[0].value) && filteredOptions[0].text != placeholder) {
20904
+ setInputChangedByAutofill(false);
20893
20905
  onSelect(filteredOptions[0].value);
20906
+
20907
+ if (isOpen) {
20908
+ setTimeout(function () {
20909
+ return _onClick();
20910
+ }, 2000);
20911
+ }
20894
20912
  }
20895
20913
 
20896
20914
  if (optionRefs.current[0].current) {
@@ -20932,13 +20950,6 @@ var Dropdown = function Dropdown(_ref8) {
20932
20950
  minHeight: "48px",
20933
20951
  minWidth: "100%",
20934
20952
  name: autocompleteValue,
20935
- onFocus: function onFocus() {
20936
- /*
20937
- if (!isOpen) {
20938
- onClick();
20939
- }
20940
- */
20941
- },
20942
20953
  onChange: function onChange(e) {
20943
20954
  console.log("current input value onChange", inputValue);
20944
20955
  console.log("input change event", e.target);
@@ -20946,6 +20957,7 @@ var Dropdown = function Dropdown(_ref8) {
20946
20957
 
20947
20958
  if (e.target.value !== inputValue) {
20948
20959
  setInputValue(e.target.value);
20960
+ setInputChangedByAutofill(true);
20949
20961
  }
20950
20962
  },
20951
20963
  padding: "12px",