Skip to content

Commit c06405e

Browse files
committed
fix(blog): 긴 TOC 스크롤 영역 복원
긴 블로그 글에서 desktop TOC가 viewport 아래로 넘치면 하단 항목에 접근할 수 없는 문제가 있었어요. native hash link 동작은 유지하고 TOC 영역에 bottom constraint와 내부 overflow scroll을 복원했어요.
1 parent 5b049fb commit c06405e

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

blog/ui/components/TableOfContents.test.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ describe('TableOfContents', () => {
3030
fireEvent.click(link);
3131

3232
expect(container.querySelector('nav')).toBeNull();
33-
expect(document.body.querySelector('nav')).not.toHaveClass('bottom-8');
34-
expect(document.body.querySelector('nav > div')).not.toHaveClass('h-full');
33+
expect(document.body.querySelector('nav')).toHaveClass('bottom-8');
34+
expect(document.body.querySelector('nav > div')).toHaveClass(
35+
'h-full',
36+
'overflow-y-auto'
37+
);
3538
expect(document.body.querySelector('ul')).toHaveClass('m-0', 'p-0');
3639
expect(link).toHaveAttribute('href', `#${item.id}`);
3740
expect(link).toHaveStyle({

blog/ui/components/TableOfContents/TableOfContents.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ export default function TableOfContents({ items }: TableOfContentsProps) {
5252

5353
return createPortal(
5454
<nav
55-
className="fixed right-8 top-20 hidden w-64 xl:block"
55+
className="fixed right-8 top-20 bottom-8 hidden w-64 xl:block"
5656
aria-label="이 글의 목차"
5757
>
58-
<div className="rounded-[var(--radius-md)] bg-[var(--color-grey-50)] p-4">
58+
<div className="h-full overflow-y-auto rounded-[var(--radius-md)] bg-[var(--color-grey-50)] p-4">
5959
<h2 className="text-sm font-semibold text-[var(--color-grey-900)] mb-4 sticky top-0 bg-[var(--color-grey-50)] pb-2">
6060
이 글의 목차
6161
</h2>

0 commit comments

Comments
 (0)