Skip to content

Commit

Permalink
fix: useIdをprefixとして再利用する
Browse files Browse the repository at this point in the history
  • Loading branch information
daiHash committed Nov 26, 2024
1 parent 6bfc5e6 commit f5cd719
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/smarthr-ui/src/components/Textarea/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, Props & ElementProps>(
ref,
) => {
const maxLettersId = useId()
const maxLettersNoticeId = useId()
const maxLettersNoticeId = `${maxLettersId}-notice`
const actualMaxLettersId = maxLetters ? maxLettersId : undefined

const textareaRef = useRef<HTMLTextAreaElement>(null)
Expand Down Expand Up @@ -173,7 +173,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, Props & ElementProps>(
[],
)

// countが連続で更新されると、スクリーンリーダーが古い値を読み上げてしまうため、メッセージ更新遅延しています
// countが連続で更新されると、スクリーンリーダーが古い値を読み上げてしまうため、メッセージの更新を遅延しています
// eslint-disable-next-line react-hooks/exhaustive-deps
const debouncedUpdateSrCounterMessage = useCallback(
debounce((value: string) => {
Expand Down Expand Up @@ -271,7 +271,6 @@ export const Textarea = forwardRef<HTMLTextAreaElement, Props & ElementProps>(
{counterVisualMessage}
</span>
</span>

<VisuallyHiddenText aria-live="polite">{srCounterMessage}</VisuallyHiddenText>
<VisuallyHiddenText id={maxLettersNoticeId}>
最大{maxLetters}文字入力できます。
Expand Down

0 comments on commit f5cd719

Please sign in to comment.