-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FE] 리뷰 작성 페이지에서 동적으로 에러가 생기는 경우, 해당 에러를 읽어주는 기능 (#891)
* feat: Checkbox 선택 여부를 스크린 리더 사용자에게 안내하는 기능 추가 * feat: 탭 접근성 강화 1. Checkbox와 CheckboxItem의 탭 포커스 분리 2. CheckboxItem에 포커싱됐을 때 엔터를 누르면 해당 체크박스를 선택할 수 있는 기능 추가 3. CheckboxItem의 focus시 outline 색상을 primary로 변경 * feat: 에러 메세지가 등장하는 경우 해당 에러 메세지 컴포넌트에 포커스를 주는 훅 작성 * feat: useFocusMessage 훅 적용 * feat: CheckboxItem을 전체 선택했을 때도 선택 여부를 알려주도록 변경 * refactor: handleKeyDown 이벤트 핸들러에서 사용하는 ChangeEvent 타입 캐스팅을 partial을 사용해 명확하게 변경 * refactor: 업데이트된 sr-only 스타일 반영
- Loading branch information
1 parent
4e30ee2
commit 060d5d3
Showing
5 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
frontend/src/pages/ReviewWritingPage/form/hooks/useFocusMessage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { useRef, useEffect } from 'react'; | ||
|
||
interface useMessageFocusProps { | ||
isMessageShown: boolean; | ||
} | ||
|
||
const useFocusMessage = <T extends HTMLElement = HTMLElement>({ isMessageShown }: useMessageFocusProps) => { | ||
const messageRef = useRef<T | null>(null); | ||
|
||
useEffect(() => { | ||
if (isMessageShown && messageRef.current) { | ||
messageRef.current.focus(); | ||
} | ||
}, [isMessageShown]); | ||
|
||
return { | ||
messageRef, | ||
}; | ||
}; | ||
|
||
export default useFocusMessage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters