@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 CHANGED
@@ -20746,6 +20746,11 @@ var Dropdown = function Dropdown(_ref8) {
20746
20746
  focusedRef = _useState12[0],
20747
20747
  setFocusedRef = _useState12[1];
20748
20748
 
20749
+ var _useState13 = React.useState(false),
20750
+ _useState14 = _slicedToArray(_useState13, 2),
20751
+ inputChangedByAutofill = _useState14[0],
20752
+ setInputChangedByAutofill = _useState14[1];
20753
+
20749
20754
  if (optionsState !== options) {
20750
20755
  setOptionsState(options);
20751
20756
  setOptionsChanged(true);
@@ -20756,10 +20761,10 @@ var Dropdown = function Dropdown(_ref8) {
20756
20761
  setOptionsChanged(false);
20757
20762
  }
20758
20763
 
20759
- var _useState13 = React.useState(null),
20760
- _useState14 = _slicedToArray(_useState13, 2),
20761
- timer = _useState14[0],
20762
- setTimer = _useState14[1];
20764
+ var _useState15 = React.useState(null),
20765
+ _useState16 = _slicedToArray(_useState15, 2),
20766
+ timer = _useState16[0],
20767
+ setTimer = _useState16[1];
20763
20768
 
20764
20769
  var optionRefs = React.useRef(_toConsumableArray(Array(options.length)).map(function () {
20765
20770
  return /*#__PURE__*/React.createRef();
@@ -20897,8 +20902,21 @@ var Dropdown = function Dropdown(_ref8) {
20897
20902
  }));
20898
20903
  }, [inputValue]);
20899
20904
  React.useEffect(function () {
20900
- if (!isOpen && filteredOptions[0] && !disabledValues.includes(filteredOptions[0].value) && filteredOptions[0].text != placeholder) {
20905
+ if (
20906
+ /*
20907
+ Either user has typed a value into input that matches a non-disabled option
20908
+ or
20909
+ user has autofilled or pasted into input a string matching a valid option
20910
+ */
20911
+ (!isOpen || inputChangedByAutofill) && filteredOptions[0] && !disabledValues.includes(filteredOptions[0].value) && filteredOptions[0].text != placeholder) {
20912
+ setInputChangedByAutofill(false);
20901
20913
  onSelect(filteredOptions[0].value);
20914
+
20915
+ if (isOpen) {
20916
+ setTimeout(function () {
20917
+ return _onClick();
20918
+ }, 2000);
20919
+ }
20902
20920
  }
20903
20921
 
20904
20922
  if (optionRefs.current[0].current) {
@@ -20940,13 +20958,6 @@ var Dropdown = function Dropdown(_ref8) {
20940
20958
  minHeight: "48px",
20941
20959
  minWidth: "100%",
20942
20960
  name: autocompleteValue,
20943
- onFocus: function onFocus() {
20944
- /*
20945
- if (!isOpen) {
20946
- onClick();
20947
- }
20948
- */
20949
- },
20950
20961
  onChange: function onChange(e) {
20951
20962
  console.log("current input value onChange", inputValue);
20952
20963
  console.log("input change event", e.target);
@@ -20954,6 +20965,7 @@ var Dropdown = function Dropdown(_ref8) {
20954
20965
 
20955
20966
  if (e.target.value !== inputValue) {
20956
20967
  setInputValue(e.target.value);
20968
+ setInputChangedByAutofill(true);
20957
20969
  }
20958
20970
  },
20959
20971
  padding: "12px",