downshift 7.2.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "downshift",
3
- "version": "7.2.1",
3
+ "version": "7.2.2",
4
4
  "description": "🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.",
5
5
  "main": "dist/downshift.cjs.js",
6
6
  "react-native": "dist/downshift.native.cjs.js",
@@ -1736,8 +1736,11 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
1736
1736
  isTouchMove: false
1737
1737
  });
1738
1738
  preact.useEffect(function () {
1739
+ if ((environment == null ? void 0 : environment.addEventListener) == null) {
1740
+ return;
1741
+ }
1739
1742
 
1740
- // The same strategy for checking if a click occurred inside or outside downsift
1743
+ // The same strategy for checking if a click occurred inside or outside downshift
1741
1744
  // as in downshift.js.
1742
1745
  var onMouseDown = function onMouseDown() {
1743
1746
  mouseAndTouchTrackersRef.current.isMouseDown = true;
@@ -3001,13 +3004,14 @@ function useCombobox(userProps) {
3001
3004
  }, []);
3002
3005
  // Reset itemRefs on close.
3003
3006
  preact.useEffect(function () {
3007
+ var _environment$document;
3004
3008
  if (!isOpen) {
3005
3009
  itemRefs.current = {};
3006
- } else if (document.activeElement !== inputRef.current) {
3010
+ } else if (((_environment$document = environment.document) == null ? void 0 : _environment$document.activeElement) !== inputRef.current) {
3007
3011
  var _inputRef$current;
3008
3012
  inputRef == null ? void 0 : (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
3009
3013
  }
3010
- }, [isOpen]);
3014
+ }, [isOpen, environment]);
3011
3015
 
3012
3016
  /* Event handler functions */
3013
3017
  var inputKeyDownHandlers = preact.useMemo(function () {
@@ -1723,8 +1723,11 @@ function useMouseAndTouchTracker(isOpen, downshiftElementRefs, environment, hand
1723
1723
  isTouchMove: false
1724
1724
  });
1725
1725
  useEffect(function () {
1726
+ if ((environment == null ? void 0 : environment.addEventListener) == null) {
1727
+ return;
1728
+ }
1726
1729
 
1727
- // The same strategy for checking if a click occurred inside or outside downsift
1730
+ // The same strategy for checking if a click occurred inside or outside downshift
1728
1731
  // as in downshift.js.
1729
1732
  var onMouseDown = function onMouseDown() {
1730
1733
  mouseAndTouchTrackersRef.current.isMouseDown = true;
@@ -2988,13 +2991,14 @@ function useCombobox(userProps) {
2988
2991
  }, []);
2989
2992
  // Reset itemRefs on close.
2990
2993
  useEffect(function () {
2994
+ var _environment$document;
2991
2995
  if (!isOpen) {
2992
2996
  itemRefs.current = {};
2993
- } else if (document.activeElement !== inputRef.current) {
2997
+ } else if (((_environment$document = environment.document) == null ? void 0 : _environment$document.activeElement) !== inputRef.current) {
2994
2998
  var _inputRef$current;
2995
2999
  inputRef == null ? void 0 : (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
2996
3000
  }
2997
- }, [isOpen]);
3001
+ }, [isOpen, environment]);
2998
3002
 
2999
3003
  /* Event handler functions */
3000
3004
  var inputKeyDownHandlers = useMemo(function () {
@@ -2006,8 +2006,11 @@
2006
2006
  isTouchMove: false
2007
2007
  });
2008
2008
  preact.useEffect(function () {
2009
+ if ((environment == null ? void 0 : environment.addEventListener) == null) {
2010
+ return;
2011
+ }
2009
2012
 
2010
- // The same strategy for checking if a click occurred inside or outside downsift
2013
+ // The same strategy for checking if a click occurred inside or outside downshift
2011
2014
  // as in downshift.js.
2012
2015
  var onMouseDown = function onMouseDown() {
2013
2016
  mouseAndTouchTrackersRef.current.isMouseDown = true;
@@ -3297,13 +3300,14 @@
3297
3300
  }, []);
3298
3301
  // Reset itemRefs on close.
3299
3302
  preact.useEffect(function () {
3303
+ var _environment$document;
3300
3304
  if (!isOpen) {
3301
3305
  itemRefs.current = {};
3302
- } else if (document.activeElement !== inputRef.current) {
3306
+ } else if (((_environment$document = environment.document) == null ? void 0 : _environment$document.activeElement) !== inputRef.current) {
3303
3307
  var _inputRef$current;
3304
3308
  inputRef == null ? void 0 : (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
3305
3309
  }
3306
- }, [isOpen]);
3310
+ }, [isOpen, environment]);
3307
3311
 
3308
3312
  /* Event handler functions */
3309
3313
  var inputKeyDownHandlers = preact.useMemo(function () {