@thecb/components 6.0.0-beta.20 → 6.0.0-beta.23

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,19 @@ 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
+ _onClick();
20909
+ }
20894
20910
  }
20895
20911
 
20896
20912
  if (optionRefs.current[0].current) {
@@ -20932,20 +20948,14 @@ var Dropdown = function Dropdown(_ref8) {
20932
20948
  minHeight: "48px",
20933
20949
  minWidth: "100%",
20934
20950
  name: autocompleteValue,
20935
- onFocus: function onFocus() {
20936
- /*
20937
- if (!isOpen) {
20938
- onClick();
20939
- }
20940
- */
20941
- },
20942
20951
  onChange: function onChange(e) {
20943
20952
  console.log("current input value onChange", inputValue);
20944
20953
  console.log("input change event", e.target);
20945
20954
  console.log("input change event value", e.target.value); // support autofill and copy/paste
20946
20955
 
20947
- if (e.tarvet.value !== inputValue) {
20956
+ if (e.target.value !== inputValue) {
20948
20957
  setInputValue(e.target.value);
20958
+ setInputChangedByAutofill(true);
20949
20959
  }
20950
20960
  },
20951
20961
  padding: "12px",