From e5774ecb3d36ae3334ed90e8567d59f329226e13 Mon Sep 17 00:00:00 2001 From: martyanov-av Date: Tue, 29 Oct 2024 16:50:23 +0300 Subject: [PATCH] fix: ref on tocitem to scroll into view --- src/components/TocItem/TocItem.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/TocItem/TocItem.tsx b/src/components/TocItem/TocItem.tsx index 8d63653c..04a7ac77 100644 --- a/src/components/TocItem/TocItem.tsx +++ b/src/components/TocItem/TocItem.tsx @@ -51,7 +51,7 @@ export const TocItem: React.FC = React.forwardRef( const content = React.createElement( href ? 'div' : 'button', { - ref: href ? null : ref, + ref, className: b('text', textProps, b('text-block')), onClick: expandable ? handleClick : undefined, ...allyButtonProps, @@ -69,10 +69,10 @@ export const TocItem: React.FC = React.forwardRef( href, target: isExternal ? '_blank' : '_self', rel: isExternal ? 'noopener noreferrer' : undefined, - 'aria-expanded': expandable ? expanded : undefined, className: b('link'), onClick: expandable && href ? handleClick : undefined, - 'aria-current': active ? 'true' : undefined, + 'aria-expanded': expandable ? expanded : undefined, + 'aria-current': active ? ('true' as const) : undefined, 'data-router-shallow': true, }; @@ -85,6 +85,7 @@ export const TocItem: React.FC = React.forwardRef( view={'flat'} onClick={handleClick} extraProps={allyButtonProps} + ref={ref} > {icon}