react-ui-suite 0.1.0 → 1.0.0

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.js CHANGED
@@ -1803,7 +1803,19 @@ function Select({
1803
1803
  const id = React11.useId();
1804
1804
  const listboxId = `${id}-listbox`;
1805
1805
  const [open, setOpen] = React11.useState(false);
1806
- const [activeIndex, setActiveIndex] = React11.useState(-1);
1806
+ const [activeIndexState, setActiveIndexState] = React11.useState(-1);
1807
+ const activeIndexRef = React11.useRef(activeIndexState);
1808
+ const setActiveIndex = React11.useCallback(
1809
+ (value2) => {
1810
+ setActiveIndexState((prev) => {
1811
+ const next = typeof value2 === "function" ? value2(prev) : value2;
1812
+ activeIndexRef.current = next;
1813
+ return next;
1814
+ });
1815
+ },
1816
+ []
1817
+ );
1818
+ const activeIndex = activeIndexState;
1807
1819
  const [selected, setSelected] = useControlledState(value, defaultValue != null ? defaultValue : null);
1808
1820
  useOutsideClick(
1809
1821
  [containerRef],
@@ -1900,7 +1912,7 @@ function Select({
1900
1912
  case "Enter":
1901
1913
  case " ":
1902
1914
  e.preventDefault();
1903
- if (activeIndex >= 0) commitSelection(activeIndex);
1915
+ if (activeIndexRef.current >= 0) commitSelection(activeIndexRef.current);
1904
1916
  break;
1905
1917
  case "Escape":
1906
1918
  e.preventDefault();