From 065a98435b7c52038b8e9b4f3f1f70376f96d6fd Mon Sep 17 00:00:00 2001 From: Jake Laderman Date: Tue, 17 Sep 2024 16:38:38 -0400 Subject: [PATCH 1/2] fix breadcrumbs and SidebarItem --- src/components/Breadcrumbs.tsx | 9 +++------ src/components/Modal.tsx | 7 +++++++ src/components/SidebarItem.tsx | 24 ++++++++++++++---------- src/components/Tooltip.tsx | 2 ++ 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/components/Breadcrumbs.tsx b/src/components/Breadcrumbs.tsx index ae0c536a..421587c6 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) => ( + + {header} + {!!header && ( {HeaderIcon && ( diff --git a/src/components/SidebarItem.tsx b/src/components/SidebarItem.tsx index 7e9079a0..af7c2023 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 e7082c66..ff7585a5 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({ } > Date: Tue, 17 Sep 2024 18:14:09 -0400 Subject: [PATCH 2/2] remove redundant body lock from modal --- src/components/Modal.tsx | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx index b662750b..f8522a4d 100644 --- a/src/components/Modal.tsx +++ b/src/components/Modal.tsx @@ -1,12 +1,6 @@ // this is just styling, actual modal logic is in ModalWrapper -import { - type ReactNode, - type Ref, - forwardRef, - useCallback, - useEffect, -} from 'react' +import { type ReactNode, type Ref, forwardRef, useCallback } from 'react' import styled, { type StyledComponentPropsWithRef, @@ -19,15 +13,13 @@ import * as Dialog from '@radix-ui/react-dialog' import { type ColorKey, type Nullable, type SeverityExt } from '../types' -import useLockedBody from '../hooks/useLockedBody' - +import Card from './Card' import CheckRoundedIcon from './icons/CheckRoundedIcon' import type createIcon from './icons/createIcon' import ErrorIcon from './icons/ErrorIcon' import InfoIcon from './icons/InfoIcon' import WarningIcon from './icons/WarningIcon' import { ModalWrapper, type ModalWrapperProps } from './ModalWrapper' -import Card from './Card' export const SEVERITIES = [ 'info', @@ -49,7 +41,6 @@ type ModalPropsType = ModalWrapperProps & { header?: ReactNode actions?: ReactNode severity?: ModalSeverity - lockBody?: boolean asForm?: boolean formProps?: StyledComponentPropsWithRef<'form'> } @@ -151,7 +142,6 @@ function ModalRef( size = form ? 'large' : 'medium', onClose, severity, - lockBody = true, asForm = false, formProps = {}, scrollable = true, @@ -163,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?.()