From 49d0b03d899c61b6c980a198ed531baeafe4dde7 Mon Sep 17 00:00:00 2001 From: Wesley Luyten Date: Tue, 7 Oct 2025 13:03:48 -0500 Subject: [PATCH] fix: tooltip and popover portal use id instead of ref for a more uniform api across all components --- packages/react/react/src/components/Popover.tsx | 5 +++-- packages/react/react/src/components/Tooltip.tsx | 5 +++-- .../react/src/skins/default/MediaSkinDefault.tsx | 16 +++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/react/react/src/components/Popover.tsx b/packages/react/react/src/components/Popover.tsx index 2ba540d2..9adf186e 100644 --- a/packages/react/react/src/components/Popover.tsx +++ b/packages/react/react/src/components/Popover.tsx @@ -53,6 +53,7 @@ interface PopoverPopupProps { interface PopoverPortalProps { children: ReactNode; container?: HTMLElement | ShadowRoot | React.MutableRefObject | null; + id?: string; } const PopoverContext = createContext(null); @@ -148,8 +149,8 @@ function PopoverPopup({ className, children }: PopoverPopupProps): JSX.Element { ); } -function PopoverPortal({ children, container }: PopoverPortalProps): JSX.Element { - return {children}; +function PopoverPortal({ children, container, id }: PopoverPortalProps): JSX.Element { + return {children}; } // Export compound component diff --git a/packages/react/react/src/components/Tooltip.tsx b/packages/react/react/src/components/Tooltip.tsx index 25a2c243..e2c23605 100644 --- a/packages/react/react/src/components/Tooltip.tsx +++ b/packages/react/react/src/components/Tooltip.tsx @@ -66,6 +66,7 @@ interface TooltipArrowProps { interface TooltipPortalProps { children: ReactNode; container?: HTMLElement | ShadowRoot | React.MutableRefObject | null; + id?: string; } const TooltipContext = createContext(null); @@ -225,8 +226,8 @@ function TooltipArrow({ className = '', children }: TooltipArrowProps): JSX.Elem ); } -function TooltipPortal({ children, container }: TooltipPortalProps): JSX.Element { - return {children}; +function TooltipPortal({ children, container, id }: TooltipPortalProps): JSX.Element { + return {children}; } // Export compound component diff --git a/packages/react/react/src/skins/default/MediaSkinDefault.tsx b/packages/react/react/src/skins/default/MediaSkinDefault.tsx index 099e6275..aa374fe8 100644 --- a/packages/react/react/src/skins/default/MediaSkinDefault.tsx +++ b/packages/react/react/src/skins/default/MediaSkinDefault.tsx @@ -1,7 +1,7 @@ import styles from './styles'; import type { PropsWithChildren } from 'react'; -import { useRef } from 'react'; +import { useId } from 'react'; import { FullscreenEnterIcon, @@ -29,11 +29,9 @@ type SkinProps = PropsWithChildren<{ }>; export default function MediaSkinDefault({ children, className = '' }: SkinProps): JSX.Element { - const containerRef = useRef(null); - const portalRef = useRef(null); - + const portalId = useId(); return ( - + {children} {/* Background gradient to help with controls contrast. */} @@ -47,7 +45,7 @@ export default function MediaSkinDefault({ children, className = '' }: SkinProps - + Play @@ -83,7 +81,7 @@ export default function MediaSkinDefault({ children, className = '' }: SkinProps - + @@ -104,7 +102,7 @@ export default function MediaSkinDefault({ children, className = '' }: SkinProps - + Enter Fullscreen @@ -115,7 +113,7 @@ export default function MediaSkinDefault({ children, className = '' }: SkinProps -
+
); }