Skip to content

fix(chat): restore focus to chat input after closing keyboard shortcuts modal#823

Open
kareena0229 wants to merge 2 commits into
param20h:devfrom
kareena0229:feat-keyboard-shortcuts-chat
Open

fix(chat): restore focus to chat input after closing keyboard shortcuts modal#823
kareena0229 wants to merge 2 commits into
param20h:devfrom
kareena0229:feat-keyboard-shortcuts-chat

Conversation

@kareena0229

Copy link
Copy Markdown
Contributor

Related Issue

Closes #821

Summary

This PR improves keyboard accessibility by automatically restoring focus to the chat input after the Keyboard Shortcuts help modal is closed.

Users can now continue typing immediately without needing to manually click the input field.

Changes Made

  • Added a reusable closeHelpModal helper.
  • Restores focus to the chat input using textareaRef.current?.focus().
  • Preserves focus restoration regardless of how the modal is dismissed:
  1. Close button (×)
  2. Clicking outside the modal
  3. Pressing Esc
  • Keeps existing modal behavior unchanged.

Why This Change?

Previously, closing the Keyboard Shortcuts modal left keyboard focus undefined, requiring keyboard users to manually click the chat input before continuing.

This update provides a smoother and more accessible keyboard workflow while following common focus management practices.

Testing

  • ✅ Modal closes via close button and focus returns to the chat input.

  • ✅ Modal closes by clicking outside and focus returns to the chat input.

  • ✅ Modal closes using the Esc key and focus returns to the chat input.

  • ✅ Existing chat functionality remains unaffected.

  • ✅ npm run build passes.

  • ✅ npm run lint completes with no errors related to this change.

  • ☑️ I have tested my changes locally.

  • ☑️ My code follows the project's coding style.

  • ☑️ This PR addresses issue [Enhancement] Restore Keyboard Focus to Chat Input After Closing Keyboard Shortcuts Modal #821.

@kareena0229 kareena0229 requested a review from param20h as a code owner July 9, 2026 21:40
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

@kareena0229 is attempting to deploy a commit to the param20h's projects Team on Vercel.

A member of the Team first needs to authorize it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Restore Keyboard Focus to Chat Input After Closing Keyboard Shortcuts Modal

1 participant