Fix input and message text rendering when using RTL keyboard with LTR device locale#6487
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe PR adds bidirectional text (BiDi) support to the message composer and theme. MessageInput now detects strong directional characters in the input value and overrides the layout direction via CompositionLocalProvider, while MessageTheme configures text styles with TextDirection.Content for automatic direction handling. ChangesBidirectional Text Support in Message Composer
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
🚀 Available in v6.40.0 |


Goal
Fix RTL (right-to-left) keyboard/layout issues in the Compose message composer and message bubbles. When typing in RTL languages (e.g. Arabic, Hebrew) on a device set to an LTR locale — or mixing RTL/LTR text — the composer input field and message text would render with the wrong alignment.
Implementation
MessageInput.kt— The composer now resolves aLayoutDirectionfrom the content of the input field by scanning for the first strong directional character (contentLayoutDirection). The innerRow(leading content + text field + trailing content) is wrapped in aCompositionLocalProviderthat overridesLocalLayoutDirectionwith the resolved direction. Empty / neutral input falls back to the device locale's layout direction.MessageTheme.kt—textStyleandquotedTextStylenow settextDirection = TextDirection.Content, so message bubbles render in the direction of the text content rather than the locale's default.🎨 UI Changes
rtl-keyboard-before.mp4
rtl-keyboard-after.mp4
rtl-keyboard-rtl-global-before.mp4
rtl-keyboard-rtl-global-after.mp4
Testing
Summary by CodeRabbit