From e15cc1e4ab23c0b41b0da96988b0c80f1709ec7c Mon Sep 17 00:00:00 2001 From: Andrey Morozov Date: Wed, 4 Dec 2024 13:09:11 +0300 Subject: [PATCH] fix: review fixes --- src/components/Popup/Popup.tsx | 7 ++++--- src/components/lab/Popover/Popover.tsx | 6 +++--- src/components/lab/Popover/README.md | 2 +- .../lab/Popover/__stories__/Popover.stories.tsx | 8 -------- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/components/Popup/Popup.tsx b/src/components/Popup/Popup.tsx index 9e12b8d46..f26b850c3 100644 --- a/src/components/Popup/Popup.tsx +++ b/src/components/Popup/Popup.tsx @@ -40,7 +40,6 @@ import {getOffsetValue, isAutoPlacement} from './utils'; import './Popup.scss'; export interface PopupProps extends DOMProps, LayerExtendableProps, QAProps { - ref?: React.Ref; children?: React.ReactNode; /** Manages `Popup` visibility */ open?: boolean; @@ -64,6 +63,8 @@ export interface PopupProps extends DOMProps, LayerExtendableProps, QAProps { floatingContext?: FloatingRootContext; /** Additional floating element props to provide interactions */ floatingProps?: Record; + /** React ref floating element is attached to */ + floatingRef?: React.Ref; /** Do not use `LayerManager` on stacking popups */ disableLayer?: boolean; /** @deprecated Add onClick handler to children */ @@ -113,7 +114,7 @@ export interface PopupProps extends DOMProps, LayerExtendableProps, QAProps { const b = block('popup'); export function Popup({ - ref, + floatingRef, keepMounted = false, hasArrow = false, open, @@ -236,7 +237,7 @@ export function Popup({ } const handleRef = useForkRef( - ref, + floatingRef, refs.setFloating, containerRef, useParentFocusTrap(), diff --git a/src/components/lab/Popover/Popover.tsx b/src/components/lab/Popover/Popover.tsx index 645a011d3..f3eb92029 100644 --- a/src/components/lab/Popover/Popover.tsx +++ b/src/components/lab/Popover/Popover.tsx @@ -39,7 +39,7 @@ export interface PopoverProps onOpenChange?: (open: boolean) => void; disabled?: boolean; content?: React.ReactNode; - trigger?: 'hover' | 'click'; + trigger?: 'click'; delay?: number | {open?: number; close?: number}; enableSafePolygon?: boolean; } @@ -89,7 +89,7 @@ export function Popover({ move: false, handleClose: enableSafePolygon ? safePolygon() : undefined, }); - const click = useClick(context, {enabled: !disabled && trigger !== 'hover'}); + const click = useClick(context, {enabled: !disabled}); const dismiss = useDismiss(context, { escapeKey: !disableEscapeKeyDown, outsidePress: !disableOutsideClick, @@ -103,9 +103,9 @@ export function Popover({ {React.cloneElement(child, {ref: anchorRef, ...getReferenceProps(child.props)})}