Skip to content

🎨 Palette: フォームの動的エラーメッセージのアクセシビリティを向上#986

Open
is0692vs wants to merge 1 commit into
stagingfrom
palette-ux-add-role-alert-to-dynamic-errors-17973489122644666835
Open

🎨 Palette: フォームの動的エラーメッセージのアクセシビリティを向上#986
is0692vs wants to merge 1 commit into
stagingfrom
palette-ux-add-role-alert-to-dynamic-errors-17973489122644666835

Conversation

@is0692vs

@is0692vs is0692vs commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

💡 What: 各ページのフォームで動的に表示されるエラーメッセージ要素に対して、role="alert" (または成功/情報メッセージの場合は role="status")を追加しました。

🎯 Why: フォームの検証エラーやAPI送信エラーなど、画面上に動的に表示されるメッセージに role="alert" を付与することで、スクリーンリーダーユーザーに対して自動的かつ即座にエラー内容が読み上げられるようになり、ユーザー体験とアクセシビリティが向上します。

Accessibility: 動的に表示されるエラー表示部に role="alert" を追加することで、スクリーンリーダーがDOMへの変更を監視し、フォーカスを移動させなくてもユーザーにエラーを通知できるようになります。


PR created automatically by Jules for task 17973489122644666835 started by @is0692vs

Greptile Summary

各フォームページの動的エラーメッセージ要素に role="alert"(成功メッセージには role="status")を追加し、スクリーンリーダーによる自動読み上げを実現するアクセシビリティ改善 PR です。

  • collections/neworgs/newpapers/[id]/editupload の 4 ページで、条件付きレンダリングされるエラー <p>/<div>role="alert" を付与し、DOM へのマウント時にスクリーンリーダーへ即時通知されるようになりました。
  • settings ページでは、エラーは role="alert"、成功・情報メッセージは role="status" と動的に切り替える実装を採用し、メッセージの重要度に応じた読み上げ優先度を適切に区別しています。

Confidence Score: 4/5

変更は各フォームへの role 属性追加のみで、既存の表示ロジックやスタイリングには一切手を加えていないため、マージは安全です。

settings ページで messageTypemessage が独立して変化した場合に既存 DOM 要素の role 属性が動的に書き換えられる可能性があり、一部のスクリーンリーダーで意図しない挙動を引き起こすリスクが小さく残っています。それ以外の 4 ファイルはシンプルな属性追加のみです。

apps/web/src/app/settings/page.tsx — role 属性の動的切り替えロジックを確認してください。

Important Files Changed

Filename Overview
.Jules/palette.md アクセシビリティ改善タスクの知見ログとして、フォームエラーへの role="alert" 追加に関する学習エントリを追記
apps/web/src/app/collections/new/page.tsx エラー表示

要素に role="alert" を追加。条件付きレンダリング構造はそのまま維持されており変更は最小限

apps/web/src/app/orgs/new/page.tsx エラー表示

要素に role="alert" を追加。collections/new と同パターン

apps/web/src/app/papers/[id]/edit/page.tsx エラー表示
要素に role="alert" を追加。既存のスタイリング(ダークモード対応含む)はそのまま維持
apps/web/src/app/settings/page.tsx エラーは role="alert"、成功・情報メッセージは role="status" と動的に切り替えるロールを追加。messageType と message が独立して変化した場合のロール動的変更に注意
apps/web/src/app/upload/page.tsx エラー表示
要素に role="alert" を追加。papers/edit と同パターン

Sequence Diagram

sequenceDiagram
    actor User
    participant Form as フォーム UI
    participant DOM
    participant SR as スクリーンリーダー

    User->>Form: フォーム送信
    Form->>Form: バリデーション / API 呼び出し
    alt エラー発生
        Form->>DOM: "role="alert" の p/div をマウント"
        DOM-->>SR: "aria-live="assertive" により即時通知"
        SR-->>User: エラーメッセージを読み上げ
    else 保存成功 (settings)
        Form->>DOM: "role="status" の p をマウント"
        DOM-->>SR: "aria-live="polite" により通知"
        SR-->>User: 成功メッセージを読み上げ
    end
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/web/src/app/settings/page.tsx:176
**ARIA ロールの動的切り替えに関する注意**

`role` 属性をすでにレンダリング済みの要素上で動的に変更することは、ARIA 仕様上推奨されていません。`message` が truthy のまま `messageType` だけが変わるケース(例:保存成功後すぐにバリデーションエラーが続けて発生する場合)では、スクリーンリーダーが変更後のロールを正しく解釈しない可能性があります。

`{message && ...}` の条件付きレンダリングにより、`message` が null → 値 に変化する際は要素が新規マウントされるため通常問題ありませんが、より確実にするには `key` プロップを活用してロールが変わるたびに要素を再マウントさせる方法が有効です(例:`key={messageType}`)。

Reviews (1): Last reviewed commit: "feat(web): add role="alert" to dynamic e..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Add `role="alert"` (or `role="status"`) to dynamically rendered form and
submission error messages across several pages to ensure they are immediately
announced by screen readers when they appear in the DOM.

Files updated:
- apps/web/src/app/collections/new/page.tsx
- apps/web/src/app/orgs/new/page.tsx
- apps/web/src/app/papers/[id]/edit/page.tsx
- apps/web/src/app/upload/page.tsx
- apps/web/src/app/settings/page.tsx

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
open-shelf Ignored Ignored Jun 10, 2026 3:01pm

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@is0692vs, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 49 minutes and 11 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: afea9ef7-9cb8-4d8a-8ee5-0bd3131f30c6

📥 Commits

Reviewing files that changed from the base of the PR and between a35977c and a9e6533.

📒 Files selected for processing (6)
  • .Jules/palette.md
  • apps/web/src/app/collections/new/page.tsx
  • apps/web/src/app/orgs/new/page.tsx
  • apps/web/src/app/papers/[id]/edit/page.tsx
  • apps/web/src/app/settings/page.tsx
  • apps/web/src/app/upload/page.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch palette-ux-add-role-alert-to-dynamic-errors-17973489122644666835

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot changed the base branch from main to staging June 10, 2026 15:01
@github-actions

Copy link
Copy Markdown

このリポジトリでは staging 先行フローを採用しています。PR のターゲットを staging に変更しました。staging で動作確認後、stagingmain の PR を作成してください。

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves form error rendering accessibility by adding role="alert" (or a dynamic role attribute) to error and status message elements across several pages, and documents this practice in .Jules/palette.md. The review feedback suggests a further improvement to ensure robust accessibility: instead of conditionally mounting the error elements, they should always remain in the DOM with their content updated dynamically, using Tailwind's empty:hidden utility to hide them when empty. This prevents certain screen readers from failing to detect the dynamically created live regions.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +352 to +356
{error && (
<p role="alert" className="text-sm text-red-600">
{error}
</p>
)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

スクリーンリーダーのアクセシビリティを高めるための role="alert" の追加は素晴らしい改善です。

さらに堅牢なアクセシビリティを実現するための改善案として、role="alert" を持つ要素を初期レンダリング時から常にDOM上に存在させておくことが推奨されます。

理由

一部のスクリーンリーダー(特にVoiceOverなど)やブラウザの組み合わせにおいて、要素自体が動的にマウント・アンマウントされる({error && <p role="alert">...)と、新しく出現したライブリージョン(role="alert")を正しく検知できず、エラーメッセージが自動的に読み上げられない場合があります。

対策

要素自体は常にDOM上に配置しておき、中身のテキスト(error)のみを動的に更新するようにします。
Tailwind CSSの empty:hidden ユーティリティクラスを使用することで、エラーメッセージが空のときは要素を非表示(display: none)にし、レイアウト崩れを防ぎつつ、スクリーンリーダーにライブリージョンを事前に登録させることができます。

※注意点として、:empty 疑似クラスは空白文字(改行やスペース)が存在すると「空ではない」と判定されてしまうため、JSXタグの間には改行を入れず {error} のみを直接記述する必要があります。

Suggested change
{error && (
<p role="alert" className="text-sm text-red-600">
{error}
</p>
)}
<p role="alert" className="text-sm text-red-600 empty:hidden">{error}</p>

Comment on lines +223 to +227
{error && (
<p role="alert" className="text-sm text-red-600">
{error}
</p>
)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

スクリーンリーダーのアクセシビリティを高めるための role="alert" の追加は素晴らしい改善です。

さらに堅牢なアクセシビリティを実現するための改善案として、role="alert" を持つ要素を初期レンダリング時から常にDOM上に存在させておくことが推奨されます。

理由

一部のスクリーンリーダー(特にVoiceOverなど)やブラウザの組み合わせにおいて、要素自体が動的にマウント・アンマウントされる({error && <p role="alert">...)と、新しく出現したライブリージョン(role="alert")を正しく検知できず、エラーメッセージが自動的に読み上げられない場合があります。

対策

要素自体は常にDOM上に配置しておき、中身のテキスト(error)のみを動的に更新するようにします。
Tailwind CSSの empty:hidden ユーティリティクラスを使用することで、エラーメッセージが空のときは要素を非表示(display: none)にし、レイアウト崩れを防ぎつつ、スクリーンリーダーにライブリージョンを事前に登録させることができます。

※注意点として、:empty 疑似クラスは空白文字(改行やスペース)が存在すると「空ではない」と判定されてしまうため、JSXタグの間には改行を入れず {error} のみを直接記述する必要があります。

Suggested change
{error && (
<p role="alert" className="text-sm text-red-600">
{error}
</p>
)}
<p role="alert" className="text-sm text-red-600 empty:hidden">{error}</p>

Comment on lines 254 to 258
{error && (
<div className="mb-6 rounded-md bg-red-50 p-4 text-sm text-red-700 dark:bg-red-900/30 dark:text-red-400">
<div role="alert" className="mb-6 rounded-md bg-red-50 p-4 text-sm text-red-700 dark:bg-red-900/30 dark:text-red-400">
{error}
</div>
)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

スクリーンリーダーのアクセシビリティを高めるための role="alert" の追加は素晴らしい改善です。

さらに堅牢なアクセシビリティを実現するための改善案として、role="alert" を持つ要素を初期レンダリング時から常にDOM上に存在させておくことが推奨されます。

理由

一部のスクリーンリーダー(特にVoiceOverなど)やブラウザの組み合わせにおいて、要素自体が動的にマウント・アンマウントされる({error && <div role="alert">...)と、新しく出現したライブリージョン(role="alert")を正しく検知できず、エラーメッセージが自動的に読み上げられない場合があります。

対策

要素自体は常にDOM上に配置しておき、中身のテキスト(error)のみを動的に更新するようにします。
Tailwind CSSの empty:hidden ユーティリティクラスを使用することで、エラーメッセージが空のときは要素を非表示(display: none)にし、レイアウト崩れを防ぎつつ、スクリーンリーダーにライブリージョンを事前に登録させることができます。

※注意点として、:empty 疑似クラスは空白文字(改行やスペース)が存在すると「空ではない」と判定されてしまうため、JSXタグの間には改行を入れず {error} のみを直接記述する必要があります。

Suggested change
{error && (
<div className="mb-6 rounded-md bg-red-50 p-4 text-sm text-red-700 dark:bg-red-900/30 dark:text-red-400">
<div role="alert" className="mb-6 rounded-md bg-red-50 p-4 text-sm text-red-700 dark:bg-red-900/30 dark:text-red-400">
{error}
</div>
)}
<div role="alert" className="mb-6 rounded-md bg-red-50 p-4 text-sm text-red-700 dark:bg-red-900/30 dark:text-red-400 empty:hidden">{error}</div>

Comment on lines 560 to 564
{error && (
<div className="rounded-2xl border border-red-200 bg-red-50 p-4 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-300">
<div role="alert" className="rounded-2xl border border-red-200 bg-red-50 p-4 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-300">
{error}
</div>
)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

スクリーンリーダーのアクセシビリティを高めるための role="alert" の追加は素晴らしい改善です。

さらに堅牢なアクセシビリティを実現するための改善案として、role="alert" を持つ要素を初期レンダリング時から常にDOM上に存在させておくことが推奨されます。

理由

一部のスクリーンリーダー(特にVoiceOverなど)やブラウザの組み合わせにおいて、要素自体が動的にマウント・アンマウントされる({error && <div role="alert">...)と、新しく出現したライブリージョン(role="alert")を正しく検知できず、エラーメッセージが自動的に読み上げられない場合があります。

対策

要素自体は常にDOM上に配置しておき、中身のテキスト(error)のみを動的に更新するようにします。
Tailwind CSSの empty:hidden ユーティリティクラスを使用することで、エラーメッセージが空のときは要素を非表示(display: none)にし、レイアウト崩れを防ぎつつ、スクリーンリーダーにライブリージョンを事前に登録させることができます。

※注意点として、:empty 疑似クラスは空白文字(改行やスペース)が存在すると「空ではない」と判定されてしまうため、JSXタグの間には改行を入れず {error} のみを直接記述する必要があります。

Suggested change
{error && (
<div className="rounded-2xl border border-red-200 bg-red-50 p-4 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-300">
<div role="alert" className="rounded-2xl border border-red-200 bg-red-50 p-4 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-300">
{error}
</div>
)}
<div role="alert" className="rounded-2xl border border-red-200 bg-red-50 p-4 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-300 empty:hidden">{error}</div>


{message && (
<p
role={messageType === "error" ? "alert" : "status"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 ARIA ロールの動的切り替えに関する注意

role 属性をすでにレンダリング済みの要素上で動的に変更することは、ARIA 仕様上推奨されていません。message が truthy のまま messageType だけが変わるケース(例:保存成功後すぐにバリデーションエラーが続けて発生する場合)では、スクリーンリーダーが変更後のロールを正しく解釈しない可能性があります。

{message && ...} の条件付きレンダリングにより、message が null → 値 に変化する際は要素が新規マウントされるため通常問題ありませんが、より確実にするには key プロップを活用してロールが変わるたびに要素を再マウントさせる方法が有効です(例:key={messageType})。

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/src/app/settings/page.tsx
Line: 176

Comment:
**ARIA ロールの動的切り替えに関する注意**

`role` 属性をすでにレンダリング済みの要素上で動的に変更することは、ARIA 仕様上推奨されていません。`message` が truthy のまま `messageType` だけが変わるケース(例:保存成功後すぐにバリデーションエラーが続けて発生する場合)では、スクリーンリーダーが変更後のロールを正しく解釈しない可能性があります。

`{message && ...}` の条件付きレンダリングにより、`message` が null → 値 に変化する際は要素が新規マウントされるため通常問題ありませんが、より確実にするには `key` プロップを活用してロールが変わるたびに要素を再マウントさせる方法が有効です(例:`key={messageType}`)。

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant