From 1ba83766d0c4f2fdbfc41b2e530465cf60032f79 Mon Sep 17 00:00:00 2001 From: EJClaw Date: Wed, 14 Oct 2026 04:21:43 +0900 Subject: [PATCH] =?UTF-8?q?=ED=9C=B4=EB=8C=80=ED=8F=B0=20=EC=B1=84?= =?UTF-8?q?=ED=8C=85=20=EC=8B=9C=ED=8A=B8:=20=EC=83=88=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=EA=B0=80=20=EC=98=AC=20=EB=95=8C=EB=A7=88?= =?UTF-8?q?=EB=8B=A4=20=EC=9E=85=EB=A0=A5=20=EC=B9=B8=20=ED=8F=AC=EC=BB=A4?= =?UTF-8?q?=EC=8A=A4=EA=B0=80=20=EB=B9=A0=EC=A0=B8=20=ED=82=A4=EB=B3=B4?= =?UTF-8?q?=EB=93=9C=EA=B0=80=20=EB=8B=AB=ED=9E=88=EB=8D=98=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C(Sheet=EA=B0=80=20onClose=EA=B0=80=20=EB=B0=94?= =?UTF-8?q?=EB=80=94=20=EB=95=8C=EB=A7=88=EB=8B=A4=20=ED=8F=AC=EC=BB=A4?= =?UTF-8?q?=EC=8A=A4=EB=A5=BC=20=EB=8B=A4=EC=8B=9C=20=EC=9E=A1=EC=9D=8C)?= =?UTF-8?q?=20=E2=80=94=20=EC=97=B4=20=EB=95=8C=20=ED=95=9C=20=EB=B2=88?= =?UTF-8?q?=EB=A7=8C=20=ED=8F=AC=EC=BB=A4=EC=8A=A4=EB=A5=BC=20=EC=98=AE?= =?UTF-8?q?=EA=B8=B0=EA=B2=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/SettingsPopup.tsx | 1 - apps/web/src/components/ui.tsx | 8 ++++++-- e2e/chat.e2e.ts | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/apps/web/src/components/SettingsPopup.tsx b/apps/web/src/components/SettingsPopup.tsx index 3dab99d..6d06a0e 100644 --- a/apps/web/src/components/SettingsPopup.tsx +++ b/apps/web/src/components/SettingsPopup.tsx @@ -47,7 +47,6 @@ export function DisplaySettings() { /** * 설정 팝업: opens over the current page so a room stays open underneath (no navigation, no leave). * `account` adds a link to the full 설정 page (nickname, records, logout); rooms leave it out because following it leaves the room. - * Pass a stable `onClose`: Sheet re-focuses itself whenever it changes. */ export function SettingsPopup({ onClose, account }: { onClose: () => void; account?: boolean }) { return ( diff --git a/apps/web/src/components/ui.tsx b/apps/web/src/components/ui.tsx index 1731bbe..6620e3a 100644 --- a/apps/web/src/components/ui.tsx +++ b/apps/web/src/components/ui.tsx @@ -66,16 +66,20 @@ export function ShareButton({ title, text, url, className = 'btn btn-secondary' export function Sheet({ onClose, children, label }: { onClose: () => void; children: ReactNode; label: string }) { const ref = useRef(null); + // Focus moves in once on open and back to the opener on close. Callers often pass a new `onClose` on every render + // (the chat sheet re-renders with each message); re-running this then pulled focus out of the chat box. + const close = useRef(onClose); + close.current = onClose; useEffect(() => { const prev = document.activeElement as HTMLElement | null; ref.current?.focus(); - const onKey = (e: KeyboardEvent) => e.key === 'Escape' && onClose(); + const onKey = (e: KeyboardEvent) => e.key === 'Escape' && close.current(); window.addEventListener('keydown', onKey); return () => { window.removeEventListener('keydown', onKey); prev?.focus?.(); }; - }, [onClose]); + }, []); return (
e.target === e.currentTarget && onClose()}>
diff --git a/e2e/chat.e2e.ts b/e2e/chat.e2e.ts index 9038e65..1f32c58 100644 --- a/e2e/chat.e2e.ts +++ b/e2e/chat.e2e.ts @@ -201,6 +201,25 @@ try { await sheet.getByRole('button', { name: '닫기' }).click(); }); + await step('휴대폰 채팅 시트: 새 메시지가 와도 입력 칸 포커스(키보드)가 그대로', async () => { + await b.getByRole('button', { name: /^채팅/ }).click(); + const sheet = b.getByRole('dialog', { name: '채팅' }); + const input = sheet.locator('input[aria-label="메시지"]'); + await input.click(); + await input.pressSequentially('치는 중'); + for (let i = 1; i <= 3; i++) { + await say(a, `치는 동안 온 메시지 ${i}`); + await sheet.locator('.chat-line', { hasText: `치는 동안 온 메시지 ${i}` }).waitFor(); + } + await b.waitForTimeout(150); + if (!(await input.evaluate((el) => el === document.activeElement))) throw new Error('the chat box lost focus when a line arrived'); + await input.pressSequentially(' 계속'); + await input.press('Enter'); + await sheet.locator('.chat-line', { hasText: '치는 중 계속' }).waitFor(); + if (!(await input.evaluate((el) => el === document.activeElement))) throw new Error('the chat box lost focus after sending'); + await sheet.getByRole('button', { name: '닫기' }).click(); + }); + await step('소리 크기: 방 막대 오른쪽 위, 기본 50, 0~100', async () => { const btn = a.locator('.room-bar').getByRole('button', { name: /^소리 크기/ }); if ((await btn.getAttribute('aria-label')) !== '소리 크기 50') throw new Error(`default: ${await btn.getAttribute('aria-label')}`);