Skip to content

Commit

Permalink
fix: ref on tocitem to scroll into view
Browse files Browse the repository at this point in the history
  • Loading branch information
martyanovandrey committed Oct 31, 2024
1 parent d452cd8 commit e5774ec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/TocItem/TocItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const TocItem: React.FC<TocItemProps> = 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,
Expand All @@ -69,10 +69,10 @@ export const TocItem: React.FC<TocItemProps> = 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,
};

Expand All @@ -85,6 +85,7 @@ export const TocItem: React.FC<TocItemProps> = React.forwardRef(
view={'flat'}
onClick={handleClick}
extraProps={allyButtonProps}
ref={ref}
>
<Button.Icon>{icon}</Button.Icon>
</Button>
Expand Down

0 comments on commit e5774ec

Please sign in to comment.