downshift 8.0.2 → 8.1.1

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.
@@ -2419,6 +2419,14 @@ function useSelect(userProps) {
2419
2419
  }
2420
2420
  previousResultCountRef.current = items.length;
2421
2421
  });
2422
+ // Focus the toggle button on first render if required.
2423
+ React.useEffect(function () {
2424
+ var focusOnOpen = getInitialValue$1(props, 'isOpen');
2425
+ if (focusOnOpen && toggleButtonRef.current) {
2426
+ toggleButtonRef.current.focus();
2427
+ }
2428
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2429
+ }, []);
2422
2430
  // Add mouse/touch events to document.
2423
2431
  var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, function () {
2424
2432
  dispatch({
@@ -3074,7 +3082,7 @@ function useCombobox(userProps) {
3074
3082
  itemRefs.current = {};
3075
3083
  } else if (((_environment$document = environment.document) == null ? void 0 : _environment$document.activeElement) !== inputRef.current) {
3076
3084
  var _inputRef$current;
3077
- inputRef == null || (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
3085
+ inputRef == null || (_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
3078
3086
  }
3079
3087
  }, [isOpen, environment]);
3080
3088
 
@@ -2405,6 +2405,14 @@ function useSelect(userProps) {
2405
2405
  }
2406
2406
  previousResultCountRef.current = items.length;
2407
2407
  });
2408
+ // Focus the toggle button on first render if required.
2409
+ useEffect(function () {
2410
+ var focusOnOpen = getInitialValue$1(props, 'isOpen');
2411
+ if (focusOnOpen && toggleButtonRef.current) {
2412
+ toggleButtonRef.current.focus();
2413
+ }
2414
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2415
+ }, []);
2408
2416
  // Add mouse/touch events to document.
2409
2417
  var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, function () {
2410
2418
  dispatch({
@@ -3060,7 +3068,7 @@ function useCombobox(userProps) {
3060
3068
  itemRefs.current = {};
3061
3069
  } else if (((_environment$document = environment.document) == null ? void 0 : _environment$document.activeElement) !== inputRef.current) {
3062
3070
  var _inputRef$current;
3063
- inputRef == null || (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
3071
+ inputRef == null || (_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
3064
3072
  }
3065
3073
  }, [isOpen, environment]);
3066
3074
 
@@ -2354,6 +2354,14 @@ function useSelect(userProps) {
2354
2354
  }
2355
2355
  previousResultCountRef.current = items.length;
2356
2356
  });
2357
+ // Focus the toggle button on first render if required.
2358
+ React.useEffect(function () {
2359
+ var focusOnOpen = getInitialValue$1(props, 'isOpen');
2360
+ if (focusOnOpen && toggleButtonRef.current) {
2361
+ toggleButtonRef.current.focus();
2362
+ }
2363
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2364
+ }, []);
2357
2365
  // Add mouse/touch events to document.
2358
2366
  var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, function () {
2359
2367
  dispatch({
@@ -2997,7 +3005,7 @@ function useCombobox(userProps) {
2997
3005
  itemRefs.current = {};
2998
3006
  } else if (((_environment$document = environment.document) == null ? void 0 : _environment$document.activeElement) !== inputRef.current) {
2999
3007
  var _inputRef$current;
3000
- inputRef == null || (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
3008
+ inputRef == null || (_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
3001
3009
  }
3002
3010
  }, [isOpen, environment]);
3003
3011
 
@@ -2414,6 +2414,14 @@ function useSelect(userProps) {
2414
2414
  }
2415
2415
  previousResultCountRef.current = items.length;
2416
2416
  });
2417
+ // Focus the toggle button on first render if required.
2418
+ React.useEffect(function () {
2419
+ var focusOnOpen = getInitialValue$1(props, 'isOpen');
2420
+ if (focusOnOpen && toggleButtonRef.current) {
2421
+ toggleButtonRef.current.focus();
2422
+ }
2423
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2424
+ }, []);
2417
2425
  // Add mouse/touch events to document.
2418
2426
  var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, function () {
2419
2427
  dispatch({
@@ -3057,7 +3065,7 @@ function useCombobox(userProps) {
3057
3065
  itemRefs.current = {};
3058
3066
  } else if (((_environment$document = environment.document) == null ? void 0 : _environment$document.activeElement) !== inputRef.current) {
3059
3067
  var _inputRef$current;
3060
- inputRef == null || (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
3068
+ inputRef == null || (_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
3061
3069
  }
3062
3070
  }, [isOpen, environment]);
3063
3071
 
@@ -3739,6 +3739,14 @@
3739
3739
  }
3740
3740
  previousResultCountRef.current = items.length;
3741
3741
  });
3742
+ // Focus the toggle button on first render if required.
3743
+ React.useEffect(function () {
3744
+ var focusOnOpen = getInitialValue$1(props, 'isOpen');
3745
+ if (focusOnOpen && toggleButtonRef.current) {
3746
+ toggleButtonRef.current.focus();
3747
+ }
3748
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3749
+ }, []);
3742
3750
  // Add mouse/touch events to document.
3743
3751
  var mouseAndTouchTrackersRef = useMouseAndTouchTracker(isOpen, [menuRef, toggleButtonRef], environment, function () {
3744
3752
  dispatch({
@@ -4394,7 +4402,7 @@
4394
4402
  itemRefs.current = {};
4395
4403
  } else if (((_environment$document = environment.document) == null ? void 0 : _environment$document.activeElement) !== inputRef.current) {
4396
4404
  var _inputRef$current;
4397
- inputRef == null || (_inputRef$current = inputRef.current) == null ? void 0 : _inputRef$current.focus();
4405
+ inputRef == null || (_inputRef$current = inputRef.current) == null || _inputRef$current.focus();
4398
4406
  }
4399
4407
  }, [isOpen, environment]);
4400
4408