Skip to content

Auto-focus message composer on keypress with user toggle#7722

Open
AlexProgrammerDE wants to merge 2 commits intosignalapp:mainfrom
AlexProgrammerDE:auto-focus-composer-on-keypress
Open

Auto-focus message composer on keypress with user toggle#7722
AlexProgrammerDE wants to merge 2 commits intosignalapp:mainfrom
AlexProgrammerDE:auto-focus-composer-on-keypress

Conversation

@AlexProgrammerDE
Copy link
Copy Markdown

@AlexProgrammerDE AlexProgrammerDE commented Feb 18, 2026

First time contributor checklist:

Contributor checklist:

  • My contribution is not related to translations.
  • My commits are in nice logical chunks with good commit messages
  • My changes are rebased on the latest main branch
  • A pnpm run ready run passes successfully (more about tests here)
  • My changes are ready to be shipped to users

Summary

  • Auto-focuses the message composition input when a printable key is pressed anywhere
    in the conversation view, matching behavior of Telegram, WhatsApp, Discord, and Slack
  • Adds a user-facing toggle in Settings > Chats (default: on) to disable for
    privacy-conscious users
  • Supersedes Focus on composition area when pressing a key #4998 with a clean implementation addressing all review feedback

Changes

  • New setting typingAutoFocus (Storage, Redux selector, Preferences UI)
  • useDocumentKeyDown hook in CompositionArea with guards for:
    • Modifier keys (Ctrl/Cmd/Alt) to avoid shortcut interference
    • Active input/textarea/select/contenteditable elements
    • Non-printable keys (arrows, F-keys, Escape, etc.)
    • Feature toggle check

Edge cases handled

  • Other input fields focused (search, settings) — no focus steal
  • Keyboard shortcuts (Ctrl+C, Cmd+V) — ignored
  • Panels/overlays open — composer not rendered, so no conflict
  • App not visible — Electron won't deliver keydown events to unfocused windows

Test plan

  • Type with composer unfocused — auto-focuses and captures keystroke
  • Type in search bar — stays in search
  • Use keyboard shortcuts — no interference
  • Disable in Settings > Chats — typing no longer auto-focuses
  • Setting persists across app restart
  • Storybook stories render correctly

Add auto-focus behavior that moves focus to the message composition
input when a printable key is pressed, matching the UX of other
major desktop messengers.

Includes a user-facing toggle in Settings > Chats (default: on)
and comprehensive guards against focus stealing from other inputs,
keyboard shortcut interference, and non-printable keys.

Supersedes signalapp#4998.
Copilot AI review requested due to automatic review settings February 18, 2026 18:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements an auto-focus feature for the message composition area that focuses the input when a printable key is pressed anywhere in the conversation view. It includes a user-facing toggle in Settings > Chats (defaulting to on) and supersedes PR #4998.

Changes:

  • Adds typingAutoFocus setting with storage, Redux selector, and UI toggle
  • Implements keyboard event listener in CompositionArea using useDocumentKeyDown hook with guards for modifier keys, active inputs, and non-printable keys
  • Updates localization strings with title and description for the new setting

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ts/types/StorageUIKeys.std.ts Adds 'typingAutoFocus' to the UI storage keys array
ts/types/Storage.d.ts Defines typingAutoFocus as a boolean in StorageAccessType
ts/state/smart/Preferences.preload.tsx Creates storage accessor and passes toggle state/handler to Preferences component
ts/state/smart/CompositionArea.preload.tsx Adds selector and passes isTypingAutoFocusEnabled to CompositionArea
ts/state/selectors/items.dom.ts Creates getTypingAutoFocus selector with default value of true
ts/components/Preferences.dom.tsx Adds checkbox UI for the typing auto-focus setting in Chats section
ts/components/Preferences.dom.stories.tsx Updates story with hasTypingAutoFocus and handler for testing
ts/components/CompositionArea.dom.tsx Implements keyboard listener with guards and calls focus() on printable key press
ts/components/CompositionArea.dom.stories.tsx Adds isTypingAutoFocusEnabled prop to story
_locales/en/messages.json Adds English strings for title and description of the new setting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AlexProgrammerDE
Copy link
Copy Markdown
Author

AlexProgrammerDE commented Feb 18, 2026

CLA is signed. This is one of they key reasons I currently do not want to switch from e.g. WhatsApp and Discord to Signal. Having to manually focus the small message input box perfectly every time I wanna send a message (while it isnt focused but I am on the right page with the right intention) is tedious and other social media desktop apps have it figured out and it works wonderfully. This PR would finally bring this quality of life feature to Signal!

@ethanp4
Copy link
Copy Markdown

ethanp4 commented Feb 21, 2026

I'd be happy to see this merged

@karlhorky
Copy link
Copy Markdown

karlhorky commented Feb 26, 2026

@scottnonnenberg-signal @josh-signal what do you think about this PR? Does this address your concerns from the other PR #4998?

cc @indutny-signal, since you are assigned to PR #4998

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.

4 participants