diff --git a/react/package-lock.json b/react/package-lock.json index d129b3a3..3ab8ac31 100644 --- a/react/package-lock.json +++ b/react/package-lock.json @@ -10,7 +10,7 @@ "license": "SEE LICENSE IN LICENSE.md", "dependencies": { "@chakra-ui/utils": "^2.0.12", - "@floating-ui/react": "^0.22.2", + "@floating-ui/react": "^0.25.2", "@fontsource/ibm-plex-mono": "^5.0.3", "country-flag-icons": "^1.4.19", "date-fns": "^2.28.0", @@ -4407,12 +4407,12 @@ } }, "node_modules/@floating-ui/react": { - "version": "0.22.3", - "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.22.3.tgz", - "integrity": "sha512-RlF+7yU3/abTZcUez44IHoEH89yDHHonkYzZocynTWbl6J6MiMINMbyZSmSKdRKdadrC+MwQLdEexu++irvZhQ==", + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.25.2.tgz", + "integrity": "sha512-3e10G9LFOgl32/SMWLBOwT7oVCtB+d5zBsU2GxTSVOvRgZexwno5MlYbc0BaXr+TR5EEGpqe9tg9OUbjlrVRnQ==", "dependencies": { - "@floating-ui/react-dom": "^1.3.0", - "aria-hidden": "^1.1.3", + "@floating-ui/react-dom": "^2.0.1", + "@floating-ui/utils": "^0.1.1", "tabbable": "^6.0.1" }, "peerDependencies": { @@ -4421,11 +4421,11 @@ } }, "node_modules/@floating-ui/react-dom": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-1.3.0.tgz", - "integrity": "sha512-htwHm67Ji5E/pROEAr7f8IKFShuiCKHwUC/UY4vC3I5jiSvGFAYnSYiZO5MlGmads+QqvUkR9ANHEguGrDv72g==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.1.tgz", + "integrity": "sha512-rZtAmSht4Lry6gdhAJDrCp/6rKN7++JnL1/Anbr/DdeyYXQPxvg/ivrbYvJulbRf4vL8b212suwMM2lxbv+RQA==", "dependencies": { - "@floating-ui/dom": "^1.2.1" + "@floating-ui/dom": "^1.3.0" }, "peerDependencies": { "react": ">=16.8.0", @@ -5238,19 +5238,6 @@ } } }, - "node_modules/@radix-ui/react-popper/node_modules/@floating-ui/react-dom": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.1.tgz", - "integrity": "sha512-rZtAmSht4Lry6gdhAJDrCp/6rKN7++JnL1/Anbr/DdeyYXQPxvg/ivrbYvJulbRf4vL8b212suwMM2lxbv+RQA==", - "dev": true, - "dependencies": { - "@floating-ui/dom": "^1.3.0" - }, - "peerDependencies": { - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, "node_modules/@radix-ui/react-portal": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@radix-ui/react-portal/-/react-portal-1.0.3.tgz", @@ -23089,21 +23076,21 @@ } }, "@floating-ui/react": { - "version": "0.22.3", - "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.22.3.tgz", - "integrity": "sha512-RlF+7yU3/abTZcUez44IHoEH89yDHHonkYzZocynTWbl6J6MiMINMbyZSmSKdRKdadrC+MwQLdEexu++irvZhQ==", + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@floating-ui/react/-/react-0.25.2.tgz", + "integrity": "sha512-3e10G9LFOgl32/SMWLBOwT7oVCtB+d5zBsU2GxTSVOvRgZexwno5MlYbc0BaXr+TR5EEGpqe9tg9OUbjlrVRnQ==", "requires": { - "@floating-ui/react-dom": "^1.3.0", - "aria-hidden": "^1.1.3", + "@floating-ui/react-dom": "^2.0.1", + "@floating-ui/utils": "^0.1.1", "tabbable": "^6.0.1" } }, "@floating-ui/react-dom": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-1.3.0.tgz", - "integrity": "sha512-htwHm67Ji5E/pROEAr7f8IKFShuiCKHwUC/UY4vC3I5jiSvGFAYnSYiZO5MlGmads+QqvUkR9ANHEguGrDv72g==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.1.tgz", + "integrity": "sha512-rZtAmSht4Lry6gdhAJDrCp/6rKN7++JnL1/Anbr/DdeyYXQPxvg/ivrbYvJulbRf4vL8b212suwMM2lxbv+RQA==", "requires": { - "@floating-ui/dom": "^1.2.1" + "@floating-ui/dom": "^1.3.0" } }, "@floating-ui/utils": { @@ -23652,17 +23639,6 @@ "@radix-ui/react-use-rect": "1.0.1", "@radix-ui/react-use-size": "1.0.1", "@radix-ui/rect": "1.0.1" - }, - "dependencies": { - "@floating-ui/react-dom": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.1.tgz", - "integrity": "sha512-rZtAmSht4Lry6gdhAJDrCp/6rKN7++JnL1/Anbr/DdeyYXQPxvg/ivrbYvJulbRf4vL8b212suwMM2lxbv+RQA==", - "dev": true, - "requires": { - "@floating-ui/dom": "^1.3.0" - } - } } }, "@radix-ui/react-portal": { diff --git a/react/package.json b/react/package.json index 6145c7d0..d3464ef1 100644 --- a/react/package.json +++ b/react/package.json @@ -33,7 +33,7 @@ }, "dependencies": { "@chakra-ui/utils": "^2.0.12", - "@floating-ui/react": "^0.22.2", + "@floating-ui/react": "^0.25.2", "@fontsource/ibm-plex-mono": "^5.0.3", "country-flag-icons": "^1.4.19", "date-fns": "^2.28.0", diff --git a/react/src/SingleSelect/components/SelectPopover/SelectPopover.tsx b/react/src/SingleSelect/components/SelectPopover/SelectPopover.tsx index 0a1f29de..f8df4f4b 100644 --- a/react/src/SingleSelect/components/SelectPopover/SelectPopover.tsx +++ b/react/src/SingleSelect/components/SelectPopover/SelectPopover.tsx @@ -1,4 +1,4 @@ -import { PropsWithChildren, useEffect, useMemo, useRef } from 'react' +import { PropsWithChildren, useLayoutEffect, useMemo, useRef } from 'react' import { Box, useMergeRefs, useOutsideClick } from '@chakra-ui/react' import { autoUpdate, @@ -20,7 +20,13 @@ export const SelectPopoverProvider = ({ const wrapperRef = useRef(null) - const { x, y, refs, reference, floating, strategy, update } = useFloating({ + const { + x, + y, + refs: { reference, floating, setFloating, setReference }, + strategy, + update, + } = useFloating({ placement: 'bottom-start', strategy: 'absolute', open: isOpen, @@ -40,7 +46,7 @@ export const SelectPopoverProvider = ({ ], }) - const mergedReferenceRefs = useMergeRefs(wrapperRef, reference) + const mergedReferenceRefs = useMergeRefs(wrapperRef, setReference) const floatingStyles = useMemo( () => ({ @@ -51,11 +57,11 @@ export const SelectPopoverProvider = ({ [strategy, x, y], ) - useEffect(() => { - if (isOpen && refs.reference.current && refs.floating.current) { - return autoUpdate(refs.reference.current, refs.floating.current, update) + useLayoutEffect(() => { + if (isOpen && reference.current && floating.current) { + return autoUpdate(reference.current, floating.current, update) } - }, [isOpen, update, refs.floating, refs.reference]) + }, [floating, isOpen, reference, update]) useOutsideClick({ ref: wrapperRef, @@ -65,7 +71,7 @@ export const SelectPopoverProvider = ({ return ( diff --git a/react/src/SingleSelect/components/SelectPopover/SelectPopoverContext.tsx b/react/src/SingleSelect/components/SelectPopover/SelectPopoverContext.tsx index e04b2e77..ae4bb680 100644 --- a/react/src/SingleSelect/components/SelectPopover/SelectPopoverContext.tsx +++ b/react/src/SingleSelect/components/SelectPopover/SelectPopoverContext.tsx @@ -2,7 +2,7 @@ import { createContext, useContext } from 'react' import { Strategy, UseFloatingReturn } from '@floating-ui/react' interface SelectPopoverContextReturn { - floatingRef: UseFloatingReturn['floating'] + floatingRef: UseFloatingReturn['refs']['setFloating'] floatingStyles: { position: Strategy top: number