Skip to content

fix(components): give each Select trigger its own id - #801

Merged
owjs3901 merged 1 commit into
mainfrom
fix/select-trigger-id
Oct 23, 2026
Merged

owjs3901 merged 1 commit into
mainfrom
fix/select-trigger-id

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Refs #692 (UI kit). main 기준의 독립 PR이며, 다른 PR의 선행 병합이 필요하지 않습니다.

요약

Select 트리거의 기본 id가 문자열 -trigger로 고정되어 있어, 한 페이지에 Select가 여러 개 있거나 Select가 중첩되면 id가 중복됩니다. listbox의 aria-labelledby도 같은 id를 참조하므로 자기 트리거를 명확하게 가리키지 못합니다.

기본 트리거 id를 listbox와 같은 기준인 ${props.id ?? generatedId}-trigger로 초기화합니다. 실제 동작 변경은 초기값 한 표현식뿐이며, 저장소 Prettier 규칙에 따라 호출을 여러 줄로 감쌌습니다. 명시적인 SelectTrigger id 우선순위는 유지합니다. 회귀 테스트 3개와 components Patch changepack을 추가했습니다.

기준 커밋: 78d7c2b2673bdeaa0870bac6a2ec424706986de7 (origin/main).

동작

경우 변경 전 변경 후
id 없는 Select 2개 트리거가 모두 id="-trigger" 각 Select의 useId()를 바탕으로 서로 다른 트리거 id 생성
<Select id="x"> 트리거 id="-trigger" 트리거 id="x-trigger"
열린 listbox aria-labelledby="-trigger"로 중복 id 참조 자기 트리거 id를 aria-labelledby로 참조
<Select id="x"><SelectTrigger id="custom-trigger"> 명시한 custom-trigger 사용 그대로 custom-trigger 사용 및 listbox 레이블 연결
중첩된 기존 스냅샷 부모와 자식 트리거가 모두 -trigger 부모 select-trigger, 자식 nested-trigger

새로 생기는 오류

없음. 의존성, 공개 API, 빌드 오류 종류를 추가하지 않습니다. WASM 빌드와 루트 빌드는 모두 통과했습니다.

남는 한계

  • 사용자가 같은 Select id 또는 같은 명시적 트리거 id를 여러 번 전달하면 여전히 중복됩니다. 사용자 지정 id의 유일성까지 강제하는 변경은 아닙니다.
  • 초기 id 생성만 고칩니다. 마운트 후 Select 루트 id를 바꿀 때의 동기화 동작은 이번 범위가 아닙니다.
  • 회귀 검증은 기존 bun-test-env-dom 렌더 환경에서 DOM id와 ARIA 연결을 확인합니다. 실제 스크린리더 조작 검증은 수행하지 않았습니다.
  • TypeScript LSP가 설치되어 있지 않고 기존에 설치가 거절되어 있어 LSP 진단은 실행할 수 없었습니다. 빌드, ESLint, 테스트 및 hook 결과를 확인했습니다.

검증

  • RED: production 수정 전 bun test ./packages/components/src/components/Select/__tests__/trigger-id.browser.test.tsx에서 1 pass / 2 fail. id 없는 두 트리거가 모두 -trigger여서 실패하고, 루트 id가 x인 경우에도 실제 id가 -trigger여서 실패했습니다. 명시적 트리거 id 테스트는 통과했습니다.
  • GREEN: 초기값 수정 후 같은 명령에서 3 pass / 0 fail, assertion 11개 통과.
  • 스냅샷: bun test ./packages/components/src/components/Select/__tests__/index.browser.test.tsx --update-snapshots에서 34 pass / 0 fail. 해당 스냅샷 파일만 변경됐고, 다음 6개 줄의 속성 값 외에는 변경이 없습니다.
    • 6행: id="-trigger" → id="select-trigger"
    • 20행: id="-trigger" → id="select-trigger"
    • 34행: id="-trigger" → id="select-trigger"
    • 41행: aria-labelledby="-trigger" → aria-labelledby="select-trigger"
    • 57행: id="-trigger" → id="nested-trigger"
    • 75행: id="-trigger" → id="select-trigger"
  • bun lint 1회: 기존 경고 20개와 초기값 줄바꿈 formatting 오류 1개를 확인했습니다. 저장소 밖의 scoped bun run lint:fix helper로 수정한 TSX 2개만 포맷했습니다. 이후 pre-commit 전체 lint는 0 errors / 20 existing warnings로 통과했습니다. 새 경고는 없습니다.
  • 루트 bun test --coverage 1회: 6657 pass / 0 fail, 165개 파일, snapshot 89개, assertion 25050개, 273.33초.
All files                                                             |  100.00 |  100.00 |
  • pre-commit hook: 첫 커밋 시도에서 전체 통과, 커밋 명령 소요 652.76초. lint → cargo tarpaulin → Bun 테스트 순으로 실행됐습니다. hook에서도 Bun 6657 pass / 0 fail, 함수·줄 **100.00%**를 확인했습니다. Rust tarpaulin은 **97.99% (23411/23892 lines)**로 종료 코드 0이었습니다. 로컬 Rust 수치를 100%로 주장하지 않습니다.
  • 커밋 직전 free physical memory: 9,055,532 KiB로 7 GiB 이상 조건 충족.
  • bun install 이후 bun.lock의 diff는 비어 있으며 working-file/HEAD blob hash가 모두 6f29191a058e5033e5270a13fc0832501f2c3931입니다. lockfile은 커밋하지 않았습니다.

Refs #692

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
...ackages/components/src/components/Select/index.tsx 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@owjs3901
owjs3901 merged commit 3290435 into main Oct 23, 2026
11 checks passed
@owjs3901
owjs3901 deleted the fix/select-trigger-id branch October 23, 2026 11:55
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.

1 participant