From 33415f6666aa69e94de7355d2d789ff2a236af60 Mon Sep 17 00:00:00 2001 From: Jake Laderman Date: Wed, 18 Sep 2024 13:01:10 -0400 Subject: [PATCH] fix: various react errors in console (#639) --- src/components/Breadcrumbs.tsx | 9 +++------ src/components/Modal.tsx | 27 +++++++++------------------ src/components/SidebarItem.tsx | 24 ++++++++++++++---------- src/components/Tooltip.tsx | 2 ++ 4 files changed, 28 insertions(+), 34 deletions(-) diff --git a/src/components/Breadcrumbs.tsx b/src/components/Breadcrumbs.tsx index ae0c536a5..421587c6b 100644 --- a/src/components/Breadcrumbs.tsx +++ b/src/components/Breadcrumbs.tsx @@ -406,6 +406,7 @@ export function Breadcrumbs({ }: BreadcrumbsProps & NavProps) { const contextCrumbs = useContext(BreadcrumbsContext)?.breadcrumbs const breadcrumbs = propsCrumbs || contextCrumbs + const nodeRef = useRef() if (!breadcrumbs) { throw Error( @@ -430,15 +431,11 @@ export function Breadcrumbs({ component is incorrect - // when not providing 'ref' prop - // @ts-expect-error - addEndListener={(node, done) => { - node?.addEventListener('refitdone', done, false) - }} + nodeRef={nodeRef} > {(state) => ( } @@ -147,7 +142,6 @@ function ModalRef( size = form ? 'large' : 'medium', onClose, severity, - lockBody = true, asForm = false, formProps = {}, scrollable = true, @@ -159,12 +153,6 @@ function ModalRef( const HeaderIcon = severityToIcon[severity ?? 'default'] const iconColorKey = severityToIconColorKey[severity ?? 'default'] - const [, setBodyLocked] = useLockedBody(open && lockBody) - - useEffect(() => { - setBodyLocked(lockBody && open) - }, [lockBody, open, setBodyLocked]) - const triggerClose = useCallback( (open: boolean) => { if (!open) onClose?.() @@ -195,6 +183,9 @@ function ModalRef( $scrollable={scrollable} $hasActions={!!actions} > + + {header} + {!!header && ( {HeaderIcon && ( diff --git a/src/components/SidebarItem.tsx b/src/components/SidebarItem.tsx index 7e9079a09..af7c2023c 100644 --- a/src/components/SidebarItem.tsx +++ b/src/components/SidebarItem.tsx @@ -12,17 +12,21 @@ type SidebarItemProps = ComponentProps & { active?: boolean } -function SidebarItemRef({ - children, - tooltip = '', - expandedLabel = '', - className, - ...props -}: SidebarItemProps) { +function SidebarItemRef( + { + children, + tooltip = '', + expandedLabel = '', + className, + ...props + }: SidebarItemProps, + ref: Ref +) { const { isExpanded } = useSidebar() return ( + ref: Ref ) { const { layout, isExpanded } = useSidebar() @@ -117,18 +121,18 @@ const ItemSC = styled.div<{ function ItemRef( { children, clickable = false, active = false, ...props }: SidebarItemProps, - ref: Ref + ref: Ref ) { const { layout, variant } = useSidebar() const isHorizontal = layout === 'horizontal' return ( {children} diff --git a/src/components/Tooltip.tsx b/src/components/Tooltip.tsx index e7082c662..ff7585a5b 100644 --- a/src/components/Tooltip.tsx +++ b/src/components/Tooltip.tsx @@ -118,6 +118,7 @@ function Tooltip({ const { x, y, + refs, reference, floating, strategy: finalStrategy, @@ -197,6 +198,7 @@ function Tooltip({ } >