Feature/enter key behavior tablet
This update adds configurable Enter-key behavior for tablet and iPad users. They can now choose whether pressing Enter should send the message or insert a newline, directly from the Preferences tab. The feature is tablet and iPad -only and mirrors the behaviour of the send button whenever “Enter to Send” is enabled.
Closes #746
Key Changes
- Added a preference allowing users to select “Send on Enter” or “Insert newline.”
- Implemented
sendViaEnterKeyinComposerInputto update state and run the sharedsendMessagepipeline. - Limited this setting to tablet and iPad devices only.
Demo Videos
For Ipad
- https://github.com/user-attachments/assets/9e29c1fb-fef9-4112-8fbb-15e0529dadda
For Tablet
- https://github.com/user-attachments/assets/3825679f-718d-4a64-9608-237d589f388d
Summary by CodeRabbit
- New Features
- Added Enter key behavior preference for tablets in Accessibility and Appearance settings, enabling users to choose between sending messages or creating new lines when pressing Enter.
✏️ Tip: You can customize this high-level summary in your review settings.
Walkthrough
The changes implement an Enter key behavior preference feature allowing users to select between sending messages or creating new lines when pressing Enter. This includes preference storage via a new constant key, tablet-specific UI settings, complex Enter key interception in the message composer, and localization strings.
Changes
| Cohort / File(s) | Summary |
|---|---|
Message Composition Logic app/containers/MessageComposer/components/ComposerInput.tsx |
Added context-based sendMessage integration, ref-based state coordination (shouldInterceptEnterRef, previousTextRef, isUpdatingNativePropsRef), tablet-specific Enter-key behavior reading from preferences, and new text update flow with sendViaEnterKey synchronization via requestAnimationFrame. Complex onChangeText and onKeyPress handlers added to manage Enter key interception and newline blocking. |
Preference Storage & Constants app/lib/constants/keys.ts |
Added new exported constant ENTER_KEY_BEHAVIOR_PREFERENCES_KEY with value 'RC_ENTER_KEY_BEHAVIOR_PREFERENCES_KEY' for persistent storage of Enter key behavior preference. |
Localization app/i18n/locales/en.json |
Added three new i18n keys: Enter_key_behavior ("Enter key behavior"), Enter_key_send_message ("Send message"), and Enter_key_new_line ("New line"). |
Settings UI Components app/views/AccessibilityAndAppearanceView/components/ListPicker.tsx |
Refactored ListPicker to support generic typing with constraint <T extends TAlertDisplayType | TEnterKeyBehavior>, added conditional mode selection ('alert' | 'enterKey'), and introduced separate option arrays (ALERT_OPTIONS vs ENTER_KEY_OPTIONS) with corresponding TEnterKeyOptions type definition. |
Accessibility Settings View app/views/AccessibilityAndAppearanceView/index.tsx |
Added tablet-only UI rendering for Enter key behavior preference, exported TEnterKeyBehavior type ('SEND' | 'NEW_LINE'), added enterKeyBehavior state management with default 'NEW_LINE', and imported the new preference key constant. Updated useLayoutEffect dependency array. |
Build Configuration ios/RocketChatRN.xcodeproj/project.pbxproj |
Removed quotes around path literals in Bugsnag script inputPaths and Firebase HEADER_SEARCH_PATHS for XCBuildConfiguration blocks (cosmetic refactoring). |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
- ComposerInput.tsx: Requires careful review of ref-based state coordination, Enter key interception logic, and the timing of microtask-based flag clearing to ensure no race conditions or missed events
- ListPicker.tsx: Generic type constraint and conditional option set selection need verification to ensure type safety across both modes
- Cross-component integration: Verify consistency between preference storage key, UI updates, and consumption in the message composer; check that defaults align
Suggested reviewers
- OtavioStasiak
- diegolmello
Poem
🐰 A rabbit hops with keys in paw,
Enter sends or lines anew—
Preferences bound without a flaw,
Tablets dance in gentler hue!
🎹✨
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Out of Scope Changes check | ⚠️ Warning | The Xcode project file changes (removing quotes from build paths) appear unrelated to the Enter-key behavior feature and may constitute scope creep beyond the intended tablet preference feature. | Review whether the iOS build configuration changes are necessary for this feature or should be submitted as a separate PR to maintain focused scope. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly summarizes the main feature: adding configurable Enter-key behavior for tablet users, which is the primary objective of the changeset. |
| Linked Issues check | ✅ Passed | The PR successfully implements the core requirement from issue #746: a user-configurable Enter-key behavior option allowing users to choose between sending messages or inserting newlines on tablets. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
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.
Comment @coderabbitai help to get the list of available commands and usage tips.