downshift 9.1.0-alpha.4 → 9.1.0-alpha.6

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.
@@ -4162,27 +4162,20 @@ var _useTagGroup = function useTagGroup(userProps) {
4162
4162
  tagGroupId: props.tagGroupId
4163
4163
  });
4164
4164
  var itemRefs = React.useRef({});
4165
+ var previousActiveIndexRef = React.useRef(activeIndex);
4165
4166
  var previousItemsLengthRef = React.useRef(items.length);
4166
- var isInitialMount = useIsInitialMount();
4167
4167
 
4168
4168
  /* Effects */
4169
4169
 
4170
4170
  useAccessibleDescription((_props$environment = props.environment) == null ? void 0 : _props$environment.document, props.removeElementDescription);
4171
4171
  React.useEffect(function () {
4172
- if (isInitialMount) {
4173
- return;
4174
- }
4175
- if (previousItemsLengthRef.current < items.length) {
4176
- return;
4177
- }
4178
- if (activeIndex >= 0 && activeIndex < Object.keys(itemRefs.current).length) {
4172
+ if (activeIndex !== -1 && previousActiveIndexRef.current !== -1 && activeIndex !== previousActiveIndexRef.current || previousItemsLengthRef.current === items.length + 1) {
4179
4173
  var _itemRefs$current$ele;
4180
4174
  (_itemRefs$current$ele = itemRefs.current[elementIds.getTagId(activeIndex)]) == null || _itemRefs$current$ele.focus();
4181
4175
  }
4182
- }, [activeIndex, elementIds, isInitialMount, items.length]);
4183
- React.useEffect(function () {
4176
+ previousActiveIndexRef.current = activeIndex;
4184
4177
  previousItemsLengthRef.current = items.length;
4185
- });
4178
+ }, [activeIndex, elementIds, items]);
4186
4179
 
4187
4180
  /* Getter functions */
4188
4181
 
@@ -4140,27 +4140,20 @@ var _useTagGroup = function useTagGroup(userProps) {
4140
4140
  tagGroupId: props.tagGroupId
4141
4141
  });
4142
4142
  var itemRefs = useRef({});
4143
+ var previousActiveIndexRef = useRef(activeIndex);
4143
4144
  var previousItemsLengthRef = useRef(items.length);
4144
- var isInitialMount = useIsInitialMount();
4145
4145
 
4146
4146
  /* Effects */
4147
4147
 
4148
4148
  useAccessibleDescription((_props$environment = props.environment) == null ? void 0 : _props$environment.document, props.removeElementDescription);
4149
4149
  useEffect(function () {
4150
- if (isInitialMount) {
4151
- return;
4152
- }
4153
- if (previousItemsLengthRef.current < items.length) {
4154
- return;
4155
- }
4156
- if (activeIndex >= 0 && activeIndex < Object.keys(itemRefs.current).length) {
4150
+ if (activeIndex !== -1 && previousActiveIndexRef.current !== -1 && activeIndex !== previousActiveIndexRef.current || previousItemsLengthRef.current === items.length + 1) {
4157
4151
  var _itemRefs$current$ele;
4158
4152
  (_itemRefs$current$ele = itemRefs.current[elementIds.getTagId(activeIndex)]) == null || _itemRefs$current$ele.focus();
4159
4153
  }
4160
- }, [activeIndex, elementIds, isInitialMount, items.length]);
4161
- useEffect(function () {
4154
+ previousActiveIndexRef.current = activeIndex;
4162
4155
  previousItemsLengthRef.current = items.length;
4163
- });
4156
+ }, [activeIndex, elementIds, items]);
4164
4157
 
4165
4158
  /* Getter functions */
4166
4159
 
@@ -4012,27 +4012,20 @@ var _useTagGroup = function useTagGroup(userProps) {
4012
4012
  tagGroupId: props.tagGroupId
4013
4013
  });
4014
4014
  var itemRefs = React.useRef({});
4015
+ var previousActiveIndexRef = React.useRef(activeIndex);
4015
4016
  var previousItemsLengthRef = React.useRef(items.length);
4016
- var isInitialMount = useIsInitialMount();
4017
4017
 
4018
4018
  /* Effects */
4019
4019
 
4020
4020
  useAccessibleDescription((_props$environment = props.environment) == null ? void 0 : _props$environment.document, props.removeElementDescription);
4021
4021
  React.useEffect(function () {
4022
- if (isInitialMount) {
4023
- return;
4024
- }
4025
- if (previousItemsLengthRef.current < items.length) {
4026
- return;
4027
- }
4028
- if (activeIndex >= 0 && activeIndex < Object.keys(itemRefs.current).length) {
4022
+ if (activeIndex !== -1 && previousActiveIndexRef.current !== -1 && activeIndex !== previousActiveIndexRef.current || previousItemsLengthRef.current === items.length + 1) {
4029
4023
  var _itemRefs$current$ele;
4030
4024
  (_itemRefs$current$ele = itemRefs.current[elementIds.getTagId(activeIndex)]) == null || _itemRefs$current$ele.focus();
4031
4025
  }
4032
- }, [activeIndex, elementIds, isInitialMount, items.length]);
4033
- React.useEffect(function () {
4026
+ previousActiveIndexRef.current = activeIndex;
4034
4027
  previousItemsLengthRef.current = items.length;
4035
- });
4028
+ }, [activeIndex, elementIds, items]);
4036
4029
 
4037
4030
  /* Getter functions */
4038
4031
 
@@ -4145,27 +4145,20 @@ var _useTagGroup = function useTagGroup(userProps) {
4145
4145
  tagGroupId: props.tagGroupId
4146
4146
  });
4147
4147
  var itemRefs = React.useRef({});
4148
+ var previousActiveIndexRef = React.useRef(activeIndex);
4148
4149
  var previousItemsLengthRef = React.useRef(items.length);
4149
- var isInitialMount = useIsInitialMount();
4150
4150
 
4151
4151
  /* Effects */
4152
4152
 
4153
4153
  useAccessibleDescription((_props$environment = props.environment) == null ? void 0 : _props$environment.document, props.removeElementDescription);
4154
4154
  React.useEffect(function () {
4155
- if (isInitialMount) {
4156
- return;
4157
- }
4158
- if (previousItemsLengthRef.current < items.length) {
4159
- return;
4160
- }
4161
- if (activeIndex >= 0 && activeIndex < Object.keys(itemRefs.current).length) {
4155
+ if (activeIndex !== -1 && previousActiveIndexRef.current !== -1 && activeIndex !== previousActiveIndexRef.current || previousItemsLengthRef.current === items.length + 1) {
4162
4156
  var _itemRefs$current$ele;
4163
4157
  (_itemRefs$current$ele = itemRefs.current[elementIds.getTagId(activeIndex)]) == null || _itemRefs$current$ele.focus();
4164
4158
  }
4165
- }, [activeIndex, elementIds, isInitialMount, items.length]);
4166
- React.useEffect(function () {
4159
+ previousActiveIndexRef.current = activeIndex;
4167
4160
  previousItemsLengthRef.current = items.length;
4168
- });
4161
+ }, [activeIndex, elementIds, items]);
4169
4162
 
4170
4163
  /* Getter functions */
4171
4164
 
@@ -5500,27 +5500,20 @@
5500
5500
  tagGroupId: props.tagGroupId
5501
5501
  });
5502
5502
  var itemRefs = React.useRef({});
5503
+ var previousActiveIndexRef = React.useRef(activeIndex);
5503
5504
  var previousItemsLengthRef = React.useRef(items.length);
5504
- var isInitialMount = useIsInitialMount();
5505
5505
 
5506
5506
  /* Effects */
5507
5507
 
5508
5508
  useAccessibleDescription((_props$environment = props.environment) == null ? void 0 : _props$environment.document, props.removeElementDescription);
5509
5509
  React.useEffect(function () {
5510
- if (isInitialMount) {
5511
- return;
5512
- }
5513
- if (previousItemsLengthRef.current < items.length) {
5514
- return;
5515
- }
5516
- if (activeIndex >= 0 && activeIndex < Object.keys(itemRefs.current).length) {
5510
+ if (activeIndex !== -1 && previousActiveIndexRef.current !== -1 && activeIndex !== previousActiveIndexRef.current || previousItemsLengthRef.current === items.length + 1) {
5517
5511
  var _itemRefs$current$ele;
5518
5512
  (_itemRefs$current$ele = itemRefs.current[elementIds.getTagId(activeIndex)]) == null || _itemRefs$current$ele.focus();
5519
5513
  }
5520
- }, [activeIndex, elementIds, isInitialMount, items.length]);
5521
- React.useEffect(function () {
5514
+ previousActiveIndexRef.current = activeIndex;
5522
5515
  previousItemsLengthRef.current = items.length;
5523
- });
5516
+ }, [activeIndex, elementIds, items]);
5524
5517
 
5525
5518
  /* Getter functions */
5526
5519