downshift 7.2.2-alpha.0 → 7.2.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # CHANGELOG
2
+
3
+ The changelog is automatically updated using
4
+ [semantic-release](https://github.com/semantic-release/semantic-release). You
5
+ can see it on the [releases page](../../releases).
package/README.md CHANGED
@@ -57,7 +57,7 @@ has been around for a while. It established a successful pattern for making
57
57
  components accessible and functional while giving developers complete freedom
58
58
  when building the UI.
59
59
 
60
- Both _useSelect_ and _useCombobox_ support he latest ARIA combobox patterns for
60
+ Both _useSelect_ and _useCombobox_ support the latest ARIA combobox patterns for
61
61
  W3C, which _Downshift_ does not. Consequently, we strongly recommend the you use
62
62
  the hooks. The hooks have been migrated to the ARIA 1.2 combobox pattern in the
63
63
  version 7 of _downshift_. There is a [Migration Guide][migration-guide-v7] that
@@ -510,9 +510,18 @@ var Downshift = /*#__PURE__*/function () {
510
510
  };
511
511
  _this.input = null;
512
512
  _this.items = [];
513
+ // itemCount can be changed asynchronously
514
+ // from within downshift (so it can't come from a prop)
515
+ // this is why we store it as an instance and use
516
+ // getItemCount rather than just use items.length
517
+ // (to support windowing + async)
513
518
  _this.itemCount = null;
514
519
  _this.previousResultCount = 0;
515
520
  _this.timeoutIds = [];
521
+ /**
522
+ * @param {Function} fn the function to call after the time
523
+ * @param {Number} time the time to wait
524
+ */
516
525
  _this.internalSetTimeout = function (fn, time) {
517
526
  var id = setTimeout(function () {
518
527
  _this.timeoutIds = _this.timeoutIds.filter(function (i) {
@@ -567,6 +576,14 @@ var Downshift = /*#__PURE__*/function () {
567
576
  _this.selectHighlightedItem = function (otherStateToSet, cb) {
568
577
  return _this.selectItemAtIndex(_this.getState().highlightedIndex, otherStateToSet, cb);
569
578
  };
579
+ // any piece of our state can live in two places:
580
+ // 1. Uncontrolled: it's internal (this.state)
581
+ // We will call this.setState to update that state
582
+ // 2. Controlled: it's external (this.props)
583
+ // We will call this.props.onStateChange to update that state
584
+ //
585
+ // In addition, we'll call this.props.onChange if the
586
+ // selectedItem is changed.
570
587
  _this.internalSetState = function (stateToSet, cb) {
571
588
  var isItemSelected, onChangeArg;
572
589
  var onStateChangeArg = {};
@@ -649,6 +666,7 @@ var Downshift = /*#__PURE__*/function () {
649
666
  _this.props.onUserAction(onStateChangeArg, _this.getStateAndHelpers());
650
667
  });
651
668
  };
669
+ //////////////////////////// ROOT
652
670
  _this.rootRef = function (node) {
653
671
  return _this._rootNode = node;
654
672
  };
@@ -671,6 +689,7 @@ var Downshift = /*#__PURE__*/function () {
671
689
  isOpen = _this$getState.isOpen;
672
690
  return _extends__default["default"]((_extends2 = {}, _extends2[refKey] = handleRefs(ref, _this.rootRef), _extends2.role = 'combobox', _extends2['aria-expanded'] = isOpen, _extends2['aria-haspopup'] = 'listbox', _extends2['aria-owns'] = isOpen ? _this.menuId : null, _extends2['aria-labelledby'] = _this.labelId, _extends2), rest);
673
691
  };
692
+ //\\\\\\\\\\\\\\\\\\\\\\\\\\ ROOT
674
693
  _this.keyDownHandlers = {
675
694
  ArrowDown: function ArrowDown(event) {
676
695
  var _this2 = this;
@@ -755,6 +774,7 @@ var Downshift = /*#__PURE__*/function () {
755
774
  }));
756
775
  }
757
776
  };
777
+ //////////////////////////// BUTTON
758
778
  _this.buttonKeyDownHandlers = _extends__default["default"]({}, _this.keyDownHandlers, {
759
779
  ' ': function _(event) {
760
780
  event.preventDefault();
@@ -878,12 +898,16 @@ var Downshift = /*#__PURE__*/function () {
878
898
  }
879
899
  });
880
900
  };
901
+ //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ BUTTON
902
+ /////////////////////////////// LABEL
881
903
  _this.getLabelProps = function (props) {
882
904
  return _extends__default["default"]({
883
905
  htmlFor: _this.inputId,
884
906
  id: _this.labelId
885
907
  }, props);
886
908
  };
909
+ //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ LABEL
910
+ /////////////////////////////// INPUT
887
911
  _this.getInputProps = function (_temp4) {
888
912
  var _ref4 = _temp4 === void 0 ? {} : _temp4,
889
913
  onKeyDown = _ref4.onKeyDown,
@@ -944,6 +968,8 @@ var Downshift = /*#__PURE__*/function () {
944
968
  }
945
969
  });
946
970
  };
971
+ //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ INPUT
972
+ /////////////////////////////// MENU
947
973
  _this.menuRef = function (node) {
948
974
  _this._menuNode = node;
949
975
  };
@@ -962,6 +988,8 @@ var Downshift = /*#__PURE__*/function () {
962
988
  _this.getMenuProps.suppressRefError = suppressRefError;
963
989
  return _extends__default["default"]((_extends3 = {}, _extends3[refKey] = handleRefs(ref, _this.menuRef), _extends3.role = 'listbox', _extends3['aria-labelledby'] = props && props['aria-label'] ? null : _this.labelId, _extends3.id = _this.menuId, _extends3), props);
964
990
  };
991
+ //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ MENU
992
+ /////////////////////////////// ITEM
965
993
  _this.getItemProps = function (_temp7) {
966
994
  var _enabledEventHandlers;
967
995
  var _ref7 = _temp7 === void 0 ? {} : _temp7,
@@ -1025,6 +1053,7 @@ var Downshift = /*#__PURE__*/function () {
1025
1053
  'aria-selected': _this.getState().highlightedIndex === index
1026
1054
  }, eventHandlers, rest);
1027
1055
  };
1056
+ //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ITEM
1028
1057
  _this.clearItems = function () {
1029
1058
  _this.items = [];
1030
1059
  };
@@ -1232,10 +1261,7 @@ var Downshift = /*#__PURE__*/function () {
1232
1261
  isOpen: isOpen,
1233
1262
  selectedItem: selectedItem
1234
1263
  };
1235
- }
1236
-
1237
- //////////////////////////// ROOT
1238
- ;
1264
+ };
1239
1265
  _proto.componentDidMount = function componentDidMount() {
1240
1266
  var _this7 = this;
1241
1267
  /* istanbul ignore if (react-native) */
@@ -1747,8 +1773,11 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
1747
1773
  isTouchMove: false
1748
1774
  });
1749
1775
  react.useEffect(function () {
1776
+ if ((environment == null ? void 0 : environment.addEventListener) == null) {
1777
+ return;
1778
+ }
1750
1779
 
1751
- // The same strategy for checking if a click occurred inside or outside downsift
1780
+ // The same strategy for checking if a click occurred inside or outside downshift
1752
1781
  // as in downshift.js.
1753
1782
  var onMouseDown = function onMouseDown() {
1754
1783
  mouseAndTouchTrackersRef.current.isMouseDown = true;
@@ -2216,8 +2245,8 @@ function downshiftSelectReducer(state, action) {
2216
2245
  /* eslint-enable complexity */
2217
2246
 
2218
2247
  var _excluded$2 = ["onMouseLeave", "refKey", "onKeyDown", "onBlur", "ref"],
2219
- _excluded2$2 = ["onBlur", "onClick", "onPress", "onKeyDown", "refKey", "ref"],
2220
- _excluded3$1 = ["item", "index", "onMouseMove", "onClick", "onPress", "refKey", "ref", "disabled"];
2248
+ _excluded2$2 = ["onBlur", "onClick", "onKeyDown", "refKey", "ref"],
2249
+ _excluded3$1 = ["item", "index", "onMouseMove", "onClick", "refKey", "ref", "disabled"];
2221
2250
  useSelect.stateChangeTypes = stateChangeTypes$2;
2222
2251
  function useSelect(userProps) {
2223
2252
  if (userProps === void 0) {
@@ -2507,9 +2536,8 @@ function useSelect(userProps) {
2507
2536
  var _extends3;
2508
2537
  var _ref3 = _temp3 === void 0 ? {} : _temp3,
2509
2538
  onBlur = _ref3.onBlur,
2510
- onClick = _ref3.onClick;
2511
- _ref3.onPress;
2512
- var onKeyDown = _ref3.onKeyDown,
2539
+ onClick = _ref3.onClick,
2540
+ onKeyDown = _ref3.onKeyDown,
2513
2541
  _ref3$refKey = _ref3.refKey,
2514
2542
  refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
2515
2543
  ref = _ref3.ref,
@@ -2546,11 +2574,8 @@ function useSelect(userProps) {
2546
2574
  toggleButtonRef.current = toggleButtonNode;
2547
2575
  }), _extends3['aria-activedescendant'] = latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '', _extends3['aria-controls'] = elementIds.menuId, _extends3['aria-expanded'] = latest.current.state.isOpen, _extends3['aria-haspopup'] = 'listbox', _extends3['aria-labelledby'] = "" + elementIds.labelId, _extends3.id = elementIds.toggleButtonId, _extends3.role = 'combobox', _extends3.tabIndex = 0, _extends3.onBlur = callAllEventHandlers(onBlur, toggleButtonHandleBlur), _extends3), rest);
2548
2576
  if (!rest.disabled) {
2549
- /* istanbul ignore if (react-native) */
2550
- {
2551
- toggleProps.onClick = callAllEventHandlers(onClick, toggleButtonHandleClick);
2552
- toggleProps.onKeyDown = callAllEventHandlers(onKeyDown, toggleButtonHandleKeyDown);
2553
- }
2577
+ toggleProps.onClick = callAllEventHandlers(onClick, toggleButtonHandleClick);
2578
+ toggleProps.onKeyDown = callAllEventHandlers(onKeyDown, toggleButtonHandleKeyDown);
2554
2579
  }
2555
2580
  setGetterPropCallInfo('getToggleButtonProps', suppressRefError, refKey, toggleButtonRef);
2556
2581
  return toggleProps;
@@ -2561,9 +2586,8 @@ function useSelect(userProps) {
2561
2586
  itemProp = _ref5.item,
2562
2587
  indexProp = _ref5.index,
2563
2588
  onMouseMove = _ref5.onMouseMove,
2564
- onClick = _ref5.onClick;
2565
- _ref5.onPress;
2566
- var _ref5$refKey = _ref5.refKey,
2589
+ onClick = _ref5.onClick,
2590
+ _ref5$refKey = _ref5.refKey,
2567
2591
  refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
2568
2592
  ref = _ref5.ref,
2569
2593
  disabled = _ref5.disabled,
@@ -2605,10 +2629,7 @@ function useSelect(userProps) {
2605
2629
  }
2606
2630
  }), _extends4), rest);
2607
2631
  if (!disabled) {
2608
- /* istanbul ignore next (react-native) */
2609
- {
2610
- itemProps.onClick = callAllEventHandlers(onClick, itemHandleClick);
2611
- }
2632
+ itemProps.onClick = callAllEventHandlers(onClick, itemHandleClick);
2612
2633
  }
2613
2634
  itemProps.onMouseMove = callAllEventHandlers(onMouseMove, itemHandleMouseMove);
2614
2635
  return itemProps;
@@ -3020,13 +3041,14 @@ function useCombobox(userProps) {
3020
3041
  }, []);
3021
3042
  // Reset itemRefs on close.
3022
3043
  react.useEffect(function () {
3044
+ var _environment$document;
3023
3045
  if (!isOpen) {
3024
3046
  itemRefs.current = {};
3025
- } else if (document.activeElement !== inputRef.current) {
3047
+ } else if (((_environment$document = environment.document) == null ? void 0 : _environment$document.activeElement) !== inputRef.current) {
3026
3048
  var _inputRef$current;
3027
3049
  inputRef == null ? void 0 : (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
3028
3050
  }
3029
- }, [isOpen]);
3051
+ }, [isOpen, environment]);
3030
3052
 
3031
3053
  /* Event handler functions */
3032
3054
  var inputKeyDownHandlers = react.useMemo(function () {
@@ -497,9 +497,18 @@ var Downshift = /*#__PURE__*/function () {
497
497
  };
498
498
  _this.input = null;
499
499
  _this.items = [];
500
+ // itemCount can be changed asynchronously
501
+ // from within downshift (so it can't come from a prop)
502
+ // this is why we store it as an instance and use
503
+ // getItemCount rather than just use items.length
504
+ // (to support windowing + async)
500
505
  _this.itemCount = null;
501
506
  _this.previousResultCount = 0;
502
507
  _this.timeoutIds = [];
508
+ /**
509
+ * @param {Function} fn the function to call after the time
510
+ * @param {Number} time the time to wait
511
+ */
503
512
  _this.internalSetTimeout = function (fn, time) {
504
513
  var id = setTimeout(function () {
505
514
  _this.timeoutIds = _this.timeoutIds.filter(function (i) {
@@ -554,6 +563,14 @@ var Downshift = /*#__PURE__*/function () {
554
563
  _this.selectHighlightedItem = function (otherStateToSet, cb) {
555
564
  return _this.selectItemAtIndex(_this.getState().highlightedIndex, otherStateToSet, cb);
556
565
  };
566
+ // any piece of our state can live in two places:
567
+ // 1. Uncontrolled: it's internal (this.state)
568
+ // We will call this.setState to update that state
569
+ // 2. Controlled: it's external (this.props)
570
+ // We will call this.props.onStateChange to update that state
571
+ //
572
+ // In addition, we'll call this.props.onChange if the
573
+ // selectedItem is changed.
557
574
  _this.internalSetState = function (stateToSet, cb) {
558
575
  var isItemSelected, onChangeArg;
559
576
  var onStateChangeArg = {};
@@ -636,6 +653,7 @@ var Downshift = /*#__PURE__*/function () {
636
653
  _this.props.onUserAction(onStateChangeArg, _this.getStateAndHelpers());
637
654
  });
638
655
  };
656
+ //////////////////////////// ROOT
639
657
  _this.rootRef = function (node) {
640
658
  return _this._rootNode = node;
641
659
  };
@@ -658,6 +676,7 @@ var Downshift = /*#__PURE__*/function () {
658
676
  isOpen = _this$getState.isOpen;
659
677
  return _extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, _this.rootRef), _extends2.role = 'combobox', _extends2['aria-expanded'] = isOpen, _extends2['aria-haspopup'] = 'listbox', _extends2['aria-owns'] = isOpen ? _this.menuId : null, _extends2['aria-labelledby'] = _this.labelId, _extends2), rest);
660
678
  };
679
+ //\\\\\\\\\\\\\\\\\\\\\\\\\\ ROOT
661
680
  _this.keyDownHandlers = {
662
681
  ArrowDown: function ArrowDown(event) {
663
682
  var _this2 = this;
@@ -742,6 +761,7 @@ var Downshift = /*#__PURE__*/function () {
742
761
  }));
743
762
  }
744
763
  };
764
+ //////////////////////////// BUTTON
745
765
  _this.buttonKeyDownHandlers = _extends({}, _this.keyDownHandlers, {
746
766
  ' ': function _(event) {
747
767
  event.preventDefault();
@@ -865,12 +885,16 @@ var Downshift = /*#__PURE__*/function () {
865
885
  }
866
886
  });
867
887
  };
888
+ //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ BUTTON
889
+ /////////////////////////////// LABEL
868
890
  _this.getLabelProps = function (props) {
869
891
  return _extends({
870
892
  htmlFor: _this.inputId,
871
893
  id: _this.labelId
872
894
  }, props);
873
895
  };
896
+ //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ LABEL
897
+ /////////////////////////////// INPUT
874
898
  _this.getInputProps = function (_temp4) {
875
899
  var _ref4 = _temp4 === void 0 ? {} : _temp4,
876
900
  onKeyDown = _ref4.onKeyDown,
@@ -931,6 +955,8 @@ var Downshift = /*#__PURE__*/function () {
931
955
  }
932
956
  });
933
957
  };
958
+ //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ INPUT
959
+ /////////////////////////////// MENU
934
960
  _this.menuRef = function (node) {
935
961
  _this._menuNode = node;
936
962
  };
@@ -949,6 +975,8 @@ var Downshift = /*#__PURE__*/function () {
949
975
  _this.getMenuProps.suppressRefError = suppressRefError;
950
976
  return _extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, _this.menuRef), _extends3.role = 'listbox', _extends3['aria-labelledby'] = props && props['aria-label'] ? null : _this.labelId, _extends3.id = _this.menuId, _extends3), props);
951
977
  };
978
+ //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ MENU
979
+ /////////////////////////////// ITEM
952
980
  _this.getItemProps = function (_temp7) {
953
981
  var _enabledEventHandlers;
954
982
  var _ref7 = _temp7 === void 0 ? {} : _temp7,
@@ -1012,6 +1040,7 @@ var Downshift = /*#__PURE__*/function () {
1012
1040
  'aria-selected': _this.getState().highlightedIndex === index
1013
1041
  }, eventHandlers, rest);
1014
1042
  };
1043
+ //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ITEM
1015
1044
  _this.clearItems = function () {
1016
1045
  _this.items = [];
1017
1046
  };
@@ -1219,10 +1248,7 @@ var Downshift = /*#__PURE__*/function () {
1219
1248
  isOpen: isOpen,
1220
1249
  selectedItem: selectedItem
1221
1250
  };
1222
- }
1223
-
1224
- //////////////////////////// ROOT
1225
- ;
1251
+ };
1226
1252
  _proto.componentDidMount = function componentDidMount() {
1227
1253
  var _this7 = this;
1228
1254
  /* istanbul ignore if (react-native) */
@@ -1734,8 +1760,11 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
1734
1760
  isTouchMove: false
1735
1761
  });
1736
1762
  useEffect(function () {
1763
+ if ((environment == null ? void 0 : environment.addEventListener) == null) {
1764
+ return;
1765
+ }
1737
1766
 
1738
- // The same strategy for checking if a click occurred inside or outside downsift
1767
+ // The same strategy for checking if a click occurred inside or outside downshift
1739
1768
  // as in downshift.js.
1740
1769
  var onMouseDown = function onMouseDown() {
1741
1770
  mouseAndTouchTrackersRef.current.isMouseDown = true;
@@ -2203,8 +2232,8 @@ function downshiftSelectReducer(state, action) {
2203
2232
  /* eslint-enable complexity */
2204
2233
 
2205
2234
  var _excluded$2 = ["onMouseLeave", "refKey", "onKeyDown", "onBlur", "ref"],
2206
- _excluded2$2 = ["onBlur", "onClick", "onPress", "onKeyDown", "refKey", "ref"],
2207
- _excluded3$1 = ["item", "index", "onMouseMove", "onClick", "onPress", "refKey", "ref", "disabled"];
2235
+ _excluded2$2 = ["onBlur", "onClick", "onKeyDown", "refKey", "ref"],
2236
+ _excluded3$1 = ["item", "index", "onMouseMove", "onClick", "refKey", "ref", "disabled"];
2208
2237
  useSelect.stateChangeTypes = stateChangeTypes$2;
2209
2238
  function useSelect(userProps) {
2210
2239
  if (userProps === void 0) {
@@ -2494,9 +2523,8 @@ function useSelect(userProps) {
2494
2523
  var _extends3;
2495
2524
  var _ref3 = _temp3 === void 0 ? {} : _temp3,
2496
2525
  onBlur = _ref3.onBlur,
2497
- onClick = _ref3.onClick;
2498
- _ref3.onPress;
2499
- var onKeyDown = _ref3.onKeyDown,
2526
+ onClick = _ref3.onClick,
2527
+ onKeyDown = _ref3.onKeyDown,
2500
2528
  _ref3$refKey = _ref3.refKey,
2501
2529
  refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
2502
2530
  ref = _ref3.ref,
@@ -2533,11 +2561,8 @@ function useSelect(userProps) {
2533
2561
  toggleButtonRef.current = toggleButtonNode;
2534
2562
  }), _extends3['aria-activedescendant'] = latestState.isOpen && latestState.highlightedIndex > -1 ? elementIds.getItemId(latestState.highlightedIndex) : '', _extends3['aria-controls'] = elementIds.menuId, _extends3['aria-expanded'] = latest.current.state.isOpen, _extends3['aria-haspopup'] = 'listbox', _extends3['aria-labelledby'] = "" + elementIds.labelId, _extends3.id = elementIds.toggleButtonId, _extends3.role = 'combobox', _extends3.tabIndex = 0, _extends3.onBlur = callAllEventHandlers(onBlur, toggleButtonHandleBlur), _extends3), rest);
2535
2563
  if (!rest.disabled) {
2536
- /* istanbul ignore if (react-native) */
2537
- {
2538
- toggleProps.onClick = callAllEventHandlers(onClick, toggleButtonHandleClick);
2539
- toggleProps.onKeyDown = callAllEventHandlers(onKeyDown, toggleButtonHandleKeyDown);
2540
- }
2564
+ toggleProps.onClick = callAllEventHandlers(onClick, toggleButtonHandleClick);
2565
+ toggleProps.onKeyDown = callAllEventHandlers(onKeyDown, toggleButtonHandleKeyDown);
2541
2566
  }
2542
2567
  setGetterPropCallInfo('getToggleButtonProps', suppressRefError, refKey, toggleButtonRef);
2543
2568
  return toggleProps;
@@ -2548,9 +2573,8 @@ function useSelect(userProps) {
2548
2573
  itemProp = _ref5.item,
2549
2574
  indexProp = _ref5.index,
2550
2575
  onMouseMove = _ref5.onMouseMove,
2551
- onClick = _ref5.onClick;
2552
- _ref5.onPress;
2553
- var _ref5$refKey = _ref5.refKey,
2576
+ onClick = _ref5.onClick,
2577
+ _ref5$refKey = _ref5.refKey,
2554
2578
  refKey = _ref5$refKey === void 0 ? 'ref' : _ref5$refKey,
2555
2579
  ref = _ref5.ref,
2556
2580
  disabled = _ref5.disabled,
@@ -2592,10 +2616,7 @@ function useSelect(userProps) {
2592
2616
  }
2593
2617
  }), _extends4), rest);
2594
2618
  if (!disabled) {
2595
- /* istanbul ignore next (react-native) */
2596
- {
2597
- itemProps.onClick = callAllEventHandlers(onClick, itemHandleClick);
2598
- }
2619
+ itemProps.onClick = callAllEventHandlers(onClick, itemHandleClick);
2599
2620
  }
2600
2621
  itemProps.onMouseMove = callAllEventHandlers(onMouseMove, itemHandleMouseMove);
2601
2622
  return itemProps;
@@ -3007,13 +3028,14 @@ function useCombobox(userProps) {
3007
3028
  }, []);
3008
3029
  // Reset itemRefs on close.
3009
3030
  useEffect(function () {
3031
+ var _environment$document;
3010
3032
  if (!isOpen) {
3011
3033
  itemRefs.current = {};
3012
- } else if (document.activeElement !== inputRef.current) {
3034
+ } else if (((_environment$document = environment.document) == null ? void 0 : _environment$document.activeElement) !== inputRef.current) {
3013
3035
  var _inputRef$current;
3014
3036
  inputRef == null ? void 0 : (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
3015
3037
  }
3016
- }, [isOpen]);
3038
+ }, [isOpen, environment]);
3017
3039
 
3018
3040
  /* Event handler functions */
3019
3041
  var inputKeyDownHandlers = useMemo(function () {