From 353bed7ac24ebd10376731733f76c556c772fc87 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 12 Nov 2026 22:53:40 +0900 Subject: [PATCH 1/5] =?UTF-8?q?fix(design-system):=20=EA=B3=B5=ED=86=B5=20?= =?UTF-8?q?primitive=EC=9D=98=20=ED=82=A4=EB=B3=B4=EB=93=9C=C2=B7=EB=B3=B4?= =?UTF-8?q?=EC=A1=B0=EA=B8=B0=EC=88=A0=20=EB=8F=99=EC=9E=91=EC=9D=84=20?= =?UTF-8?q?=EC=95=BD=EC=86=8D=EB=8C=80=EB=A1=9C=20=EB=A7=9E=EC=B6=98?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 공통 primitive가 디자인 시스템 설계 8.1·8.2절과 WCAG 2.2 AA 약속을 어긴다. - Popover가 이름 없는 role="dialog"를 그린다(1112/05-10). - Dialog 안의 Menu·Popover·Tooltip에서 Escape를 누르면 Dialog까지 닫힌다. Dialog가 안쪽이 처리한 Escape를 보지 않는다(05-11). - SearchField는 required 기호만, Checkbox는 상태만 있다(05-13). - Toast를 닫기 버튼으로 닫으면 포커스가 body로 떨어진다(05-14). - TextArea 글자 수가 (암묵 status)이라 글자마다 발표되고 입력과 이어지지 않는다(05-17). - 라우트 h1의 :focus outline 제거가 layer 순서로 키보드 :focus-visible 표시까지 지운다(05-02). Tooltip이 pointer-events: none과 틈 때문에 포인터를 설명 위로 옮기면 사라진다(1.4.13, 05-06). - 홈 readiness 목록이 role 없는 div에 aria-label을 단다(05-15). - fe-a11y·fe-ux 스킬이 제출 실패 때 오류 요약으로 포커스가 간다고 적는다. 코드는 첫 오류 필드로 보낸다(05-09). 고른 방법: Popover는 trigger id로 이름을 받는다. Popover·Tooltip은 Escape를 capture 단계에서 받아 preventDefault하고, Dialog는 기본 동작이 막힌 Escape(과 그 뒤 cancel)를 넘긴다. Tooltip은 보일 때(hover·focus)만 Escape를 가진다. 숨은 tooltip이 다른 Dialog의 Escape를 막지 않게 하려는 것이다. Toast 닫기는 다음 toast의 닫기 버튼, 없으면 toast로 들어오기 전 요소로 포커스를 돌린다. TextArea 글자 수는 aria-describedby로 잇고 0에 닿을 때만 따로 발표한다. h1은 :focus:not(:focus-visible)만 outline을 지운다. Tooltip은 보일 때만 포인터를 받고 ::before 다리로 틈을 메운다. 버린 대안: Dialog가 안쪽 layer 목록을 들고 Escape를 나누기(primitive끼리 묶인다). 위험·한계: native 가 막힌 keydown 뒤에도 cancel을 쏘는지는 브라우저마다 다를 수 있어, Dialog는 같은 task의 cancel 하나를 넘긴다. Toast가 돌려줄 요소가 지워졌으면 포커스를 옮기지 않는다. 시각 골든이 바뀌는지는 desktop test:visual로 본다. 검증: 새 component 시험(tests/component/design-system-a11y.test.tsx, starter-pages), e2e(app-shell focus ring, 세 엔진), storybook(tooltip hover)의 RED·GREEN은 desktop에서 돌려 PR 본문에 적는다. Refs: 1112/05-02, 1112/05-06, 1112/05-09, 1112/05-10, 1112/05-11, 1112/05-13, 1112/05-14, 1112/05-15, 1112/05-17 --- .claude/skills/fe-a11y/SKILL.md | 2 +- .claude/skills/fe-ux/SKILL.md | 2 +- .../design-system/primitives/checkbox.tsx | 6 +- .../design-system/primitives/dialog.tsx | 17 +- .../design-system/primitives/popover.tsx | 18 +- .../design-system/primitives/search-field.tsx | 3 + .../design-system/primitives/text-area.tsx | 73 +++--- .../design-system/primitives/toast.tsx | 35 ++- .../design-system/primitives/tooltip.tsx | 38 +++- src/presentation/pages/home-page.tsx | 2 +- src/presentation/styles/theme/primitives.css | 12 + src/presentation/styles/theme/templates.css | 4 +- tests/component/design-system-a11y.test.tsx | 212 ++++++++++++++++++ tests/component/starter-pages.test.tsx | 12 +- tests/e2e/app-shell.spec.ts | 24 ++ tests/storybook/galleries.spec.ts | 16 ++ 16 files changed, 424 insertions(+), 52 deletions(-) create mode 100644 tests/component/design-system-a11y.test.tsx diff --git a/.claude/skills/fe-a11y/SKILL.md b/.claude/skills/fe-a11y/SKILL.md index eb80cea5..98ef2c2e 100644 --- a/.claude/skills/fe-a11y/SKILL.md +++ b/.claude/skills/fe-a11y/SKILL.md @@ -51,7 +51,7 @@ paths: 폼 -- [ ] label·설명·오류가 같은 ID 체계와 `aria-describedby`로 연결된다(M5). required는 기호와 programmatic 상태를 함께 가진다. 제출 실패 시 오류 요약으로 포커스가 간다. — DS 8.3절 +- [ ] label·설명·오류가 같은 ID 체계와 `aria-describedby`로 연결된다(M5). required는 기호와 programmatic 상태를 함께 가진다. 입력 오류로 제출이 실패하면 첫 오류 필드로 포커스가 가고, 오류 요약은 그 필드들로 가는 링크다(`src/presentation/forms/use-app-form.ts` `focusFirstError`). 입력 오류가 아닌 실패는 feedback 자리가 포커스를 받는다. — DS 8.3절 - [ ] IME 조합 중에 검증하거나 제출하지 않는다. — DS 8.1절 시각 diff --git a/.claude/skills/fe-ux/SKILL.md b/.claude/skills/fe-ux/SKILL.md index 3cb18f56..afa7fc08 100644 --- a/.claude/skills/fe-ux/SKILL.md +++ b/.claude/skills/fe-ux/SKILL.md @@ -58,7 +58,7 @@ paths: 폼 -- [ ] label·설명·오류가 연결되고, 제출 실패 시 오류 요약으로 포커스가 가며, 요약 항목은 그 필드로 간다. — `docs/design/2026-07-26-design-system-platform-design.md` 8.3절 +- [ ] label·설명·오류가 연결되고, 입력 오류로 제출이 실패하면 첫 오류 필드로 포커스가 가며, 오류 요약 항목은 그 필드로 간다(`src/presentation/forms/use-app-form.ts` `focusFirstError`). — `docs/design/2026-07-26-design-system-platform-design.md` 8.3절 - [ ] 409를 검증 오류로 위장하지 않는다. 이탈 확인(`useDirtyNavigationGuard`)은 성공 저장 뒤 풀고 이동한다. — `docs/design/2026-07-26-typescript-state-and-data-flow-design.md` 8절, `docs/design/2026-07-26-routing-pages-and-patterns-design.md` 6.4절 - [ ] 자동 완성·IME·붙여넣기·비밀번호 관리자를 막지 않는다. 입력을 loading skeleton으로 덮지 않는다. — data-flow 8절 diff --git a/src/presentation/design-system/primitives/checkbox.tsx b/src/presentation/design-system/primitives/checkbox.tsx index bfce9843..b132724b 100644 --- a/src/presentation/design-system/primitives/checkbox.tsx +++ b/src/presentation/design-system/primitives/checkbox.tsx @@ -42,7 +42,11 @@ export const Checkbox = forwardRef( }} type="checkbox" /> - {label} + + {label} + {/* 1112/05-13. The symbol as Field draws it; the state is on the input. */} + {props.required ? : null} + {description ? (

diff --git a/src/presentation/design-system/primitives/dialog.tsx b/src/presentation/design-system/primitives/dialog.tsx index fcb0ea3b..8e1563d2 100644 --- a/src/presentation/design-system/primitives/dialog.tsx +++ b/src/presentation/design-system/primitives/dialog.tsx @@ -41,6 +41,7 @@ export const Dialog = forwardRef( const dialogRef = useRef(null); const previousFocusRef = useRef(null); const focusRestoreGenerationRef = useRef(0); + const innerEscapeRef = useRef(false); const titleId = useId(); const descriptionId = useId(); useImperativeHandle(forwardedRef, () => dialogRef.current!, []); @@ -103,16 +104,26 @@ export const Dialog = forwardRef( className={`ui-dialog ${className}`.trim()} onCancel={(event) => { event.preventDefault(); + // The Escape that fired this cancel closed an inner layer. + if (innerEscapeRef.current) return; onClose(); }} onClick={(event) => { if (event.target === event.currentTarget) onClose(); }} onKeyDown={(event) => { - if (event.key === "Escape") { - event.preventDefault(); - onClose(); + if (event.key !== "Escape") return; + // 1112/05-11. A Menu, Popover or Tooltip inside handled this Escape + // (it prevented the default): it closes that layer, not the Dialog. + if (event.defaultPrevented) { + innerEscapeRef.current = true; + globalThis.setTimeout(() => { + innerEscapeRef.current = false; + }, 0); + return; } + event.preventDefault(); + onClose(); }} ref={dialogRef} > diff --git a/src/presentation/design-system/primitives/popover.tsx b/src/presentation/design-system/primitives/popover.tsx index 98e1438d..27ec21d7 100644 --- a/src/presentation/design-system/primitives/popover.tsx +++ b/src/presentation/design-system/primitives/popover.tsx @@ -12,6 +12,7 @@ export function Popover({ triggerLabel, children }: PopoverProps) { const rootRef = useRef(null); const triggerRef = useRef(null); const contentId = useId(); + const triggerId = useId(); useEffect(() => { if (!open) return; @@ -24,17 +25,20 @@ export function Popover({ triggerLabel, children }: PopoverProps) { triggerRef.current?.focus(); } } + // Capture phase, and the default prevented: the Escape closes this + // layer only, not a Dialog around it (1112/05-11). function closeOnEscape(event: KeyboardEvent) { - if (event.key === "Escape") { + if (event.key === "Escape" && !event.defaultPrevented) { + event.preventDefault(); setOpen(false); triggerRef.current?.focus(); } } document.addEventListener("pointerdown", closeOutside); - document.addEventListener("keydown", closeOnEscape); + document.addEventListener("keydown", closeOnEscape, true); return () => { document.removeEventListener("pointerdown", closeOutside); - document.removeEventListener("keydown", closeOnEscape); + document.removeEventListener("keydown", closeOnEscape, true); }; }, [open]); @@ -43,6 +47,7 @@ export function Popover({ triggerLabel, children }: PopoverProps) { {open ? ( -