Skip to content

[#214] react-pdf a태그 부모 요소 크기 설정#215

Closed
ttppggnnss wants to merge 10 commits into
mainfrom
feature/214
Closed

[#214] react-pdf a태그 부모 요소 크기 설정#215
ttppggnnss wants to merge 10 commits into
mainfrom
feature/214

Conversation

@ttppggnnss

@ttppggnnss ttppggnnss commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

Describe your changes

  • Annotation.tsx 에서 drawAnnotation 함수 내에서 a 태그의 스타일을 직접 설정하는 부분 외에,
    실제로 a 태그의 부모 요소 즉, firstChildren 에 width 와 height 가 설정되지 않아서 a 태그의 width: 100% 가 제대로 적용되지 않는 문제
  • 부모 요소 크기 viewport 기반 명시적 설정 추가

Request

@ttppggnnss ttppggnnss requested a review from 2-one-week April 14, 2026 05:01
@ttppggnnss ttppggnnss self-assigned this Apr 14, 2026
@ttppggnnss ttppggnnss requested a review from a team as a code owner April 14, 2026 05:01
@npayfebot

npayfebot commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

✅ Changeset detected

Latest commit: 7149f69

@naverpay/react-pdf package have detected changes.

If no version change is needed, please add skip-detect-change to the label.

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@naverpay/react-pdf 🐛 Patch
powered by: naverpay changeset detect-add actions

@npayfebot

npayfebot commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

NPM Packages

📦 @naverpay/react-pdf

Total Sizes: 22 kB

Total Changes: +24 B (0%)

File Status Previous Size Updated Size Changed
/dist/esm/components/layer/Annotation.mjs 🛠️ 1.01 kB 1.02 kB +12 B (+1%)
/dist/cjs/components/layer/Annotation.js 🛠️ 1.08 kB 1.09 kB +12 B (+1%)
ℹ️ View Unchanged Files
File Status Previous Size Updated Size Changed
/dist/esm/index.mjs - 310 B 310 B -
/dist/esm/utils/text.mjs - 567 B 567 B -
/dist/esm/utils/pdf.mjs - 1.21 kB 1.21 kB -
/dist/esm/utils/link-service.mjs - 843 B 843 B -
/dist/esm/utils/debounce.mjs - 148 B 148 B -
/dist/esm/hooks/usePdfViewerPageWidth.mjs - 439 B 439 B -
/dist/esm/hooks/useIsomorphicLayoutEffect.mjs - 136 B 136 B -
/dist/esm/hooks/useInfiniteScroll.mjs - 303 B 303 B -
/dist/esm/contexts/pdf.mjs - 308 B 308 B -
/dist/esm/contexts/page.mjs - 447 B 447 B -
/dist/esm/components/PdfViewer.module.mjs - 116 B 116 B -
/dist/esm/components/PdfViewer.mjs - 1.25 kB 1.25 kB -
/dist/esm/components/Pages.mjs - 902 B 902 B -
/dist/esm/components/page/Canvas.mjs - 579 B 579 B -
/dist/esm/components/layer/Text.module.mjs - 108 B 108 B -
/dist/esm/components/layer/Text.mjs - 1.25 kB 1.25 kB -
/dist/esm/components/layer/Annotation.module.mjs - 505 B 505 B -
/dist/cjs/index.js - 406 B 406 B -
/dist/cjs/utils/text.js - 630 B 630 B -
/dist/cjs/utils/pdf.js - 1.28 kB 1.28 kB -
/dist/cjs/utils/link-service.js - 845 B 845 B -
/dist/cjs/utils/debounce.js - 211 B 211 B -
/dist/cjs/hooks/usePdfViewerPageWidth.js - 440 B 440 B -
/dist/cjs/hooks/useIsomorphicLayoutEffect.js - 192 B 192 B -
/dist/cjs/hooks/useInfiniteScroll.js - 300 B 300 B -
/dist/cjs/contexts/pdf.js - 375 B 375 B -
/dist/cjs/contexts/page.js - 516 B 516 B -
/dist/cjs/components/PdfViewer.module.js - 206 B 206 B -
/dist/cjs/components/PdfViewer.js - 1.31 kB 1.31 kB -
/dist/cjs/components/Pages.js - 978 B 978 B -
/dist/cjs/components/page/Canvas.js - 645 B 645 B -
/dist/cjs/components/layer/Text.module.js - 118 B 118 B -
/dist/cjs/components/layer/Text.js - 1.33 kB 1.33 kB -
/dist/cjs/components/layer/Annotation.module.js - 673 B 673 B -

powered by: naverpay size-action

@ttppggnnss

Copy link
Copy Markdown
Collaborator Author

/canary-publish

1 similar comment
@2-one-week

Copy link
Copy Markdown
Member

/canary-publish

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The annotation layer size fix is correct in intent, but the inline comment flags a nit: Math.floor() should be applied to match Canvas.tsx and Text.tsx patterns.

Extended reasoning...

Overview

This single-file PR adds explicit viewport-based width/height to the annotation layer's first child element (lines 79-80) and adds cursor: pointer to <a> tags inside the annotation layer (line 91). It fixes issue #214 where the parent element of <a> tags lacked explicit dimensions, causing hit-area misalignment.

Security Risks

No security risks. The changes are purely CSS style assignments on DOM elements rendered from PDF annotations.

Level of Scrutiny

Low-to-medium. The fix is straightforward and addresses a real rendering issue. The only concern is the consistency nit already flagged by the inline comment: Canvas.tsx (line 37-38) and Text.tsx (line 99-100) both apply Math.floor() to viewport dimensions before converting to CSS pixels, but the new code does not. This is a minor nit — the sub-pixel difference is visually invisible — but fixing it would keep the codebase consistent.

Other Factors

The cursor: pointer addition is clearly correct. The parent-size fix is logically sound. No test changes are included, which is expected for a layout/style fix. The overall change is small and self-contained.

Comment thread packages/react-pdf/src/components/layer/Annotation.tsx Outdated
@2-one-week

Copy link
Copy Markdown
Member

/canary-publish

Comment thread packages/react-pdf/src/components/layer/Annotation.tsx Outdated

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Math.floor() fix was applied, but the concern about setting viewport dimensions on children[0] (the first annotation's section element) instead of the layer container was marked resolved without a code change — the structural issue is still present.

Extended reasoning...

Overview

This PR modifies Annotation.tsx to add explicit width/height sizing to an annotation DOM element, plus a cursor:pointer style on anchor tags. The changeset file is a routine patch entry.

Prior Review History

Two earlier passes from this bot raised concerns. The first flagged missing Math.floor() which was correctly addressed in commit d90d6cb. A third-pass inline comment at line 83 raised a structural issue: in pdfjs-dist v4, AnnotationLayer.render() appends individual section elements directly to the container div with no intermediate wrapper. children[0] is therefore the first annotation's section, not a parent container. The author marked that inline comment as resolved, but the code remains unchanged.

Security Risks

No auth, crypto, or permissions code is touched. The risk is functional correctness — link hit areas and cursor styling — not a security concern.

Level of Scrutiny

The fix is in the PDF annotation layer rendering path. Setting full-viewport dimensions on the first annotation's section can expand its click target to cover the entire page, and subsequent annotations' anchor tags never receive cursor:pointer or positional overrides. This warrants a human review before merging.

Other Factors

The inline comment was resolved without a corresponding code change. Since resolved comments are collapsed in the GitHub UI, the concern may not be visible to other reviewers. A human reviewer should verify whether the firstChildren assumption is valid for the pdfjs-dist version in use, or whether the fix should target element directly.

@yujeong-jeon

Copy link
Copy Markdown
Contributor

/canary-publish

@npayfebot

This comment was marked as outdated.

부모 요소(element)에 viewport 크기를 설정하여 모든 annotation의
a 태그가 올바른 클릭 영역을 가지도록 개선했습니다.

변경사항:
- annotation layer 컨테이너에 viewport 기반 크기 설정
- 첫 번째 annotation만이 아닌 모든 a 태그에 스타일 적용
- cursor: pointer 스타일 추가로 링크 UX 개선
- unused variable 제거 및 타입 캐스팅 간소화
- 코드 의도를 명확히 하는 주석 추가

이전 코드는 children[0](첫 번째 annotation section)에만 크기를
설정했지만, 이제는 element 자체에 설정하여 모든 annotation의
a 태그가 올바르게 처리됩니다.
@ttppggnnss

Copy link
Copy Markdown
Collaborator Author

/canary-publish

@npayfebot

This comment was marked as outdated.

Comment thread packages/react-pdf/src/components/layer/Annotation.tsx Outdated
Comment thread packages/react-pdf/src/components/layer/Annotation.module.scss
annotation layer 컨테이너에 position: absolute를 적용하여
TextLayer와 동일한 패턴으로 normal flow에서 제거.
명시적 width/height 설정 시 페이지 높이가 2배로 늘어나는 문제 방지.
CSS Module 스코핑으로 동작하지 않는 cursor: pointer 규칙 제거.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.

Once credits are available, push a new commit or reopen this pull request to trigger a review.

@ttppggnnss

This comment was marked as outdated.

@npayfebot

This comment was marked as outdated.

sehoon.kim added 2 commits April 15, 2026 17:38
viewport 크기 동기화 방식을 TextLayer와 동일하게 inline style로
변경하여 클릭 영역 정확성을 보장하고, 불필요한 스타일을 제거하여
안정성을 높였습니다.

변경사항:
- annotation layer 크기 설정을 return 문 inline style로 이동
- SCSS에서 width/height 100% 제거 (동적 viewport 동기화 불가)
- a 태그 스타일 간소화 (cursor: pointer만 유지)
- annotation layer 구조 개선 (position: relative 명시)

이전 방식은 CSS 100%로 인한 viewport 불일치와 스케일 변경 시
클릭 영역 버그가 있었으나, 이제 TextLayer와 동일한 패턴으로
안정적인 동작을 보장합니다.
SCSS와 inline style 간 충돌을 제거하고 스타일을 정리하여
코드 일관성과 유지보수성을 개선했습니다.

변경사항:
- SCSS에서 width/height 100% 제거 (inline style과 충돌 방지)
- cursor: pointer를 SCSS로 통합 (스타일 일관성)
- 불필요한 a 태그 처리 코드 제거
- error handling 주석 개선

이제 annotation layer는 TextLayer와 동일한 패턴으로
viewport 크기를 동기화하고, 스타일은 SCSS에서 일관되게
관리됩니다.
@ttppggnnss

This comment was marked as outdated.

@ttppggnnss

This comment was marked as outdated.

@ttppggnnss ttppggnnss closed this Apr 15, 2026
@ttppggnnss ttppggnnss deleted the feature/214 branch April 15, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants