Skip to content

Fix input and message text rendering when using RTL keyboard with LTR device locale#6487

Merged
aleksandar-apostolov merged 1 commit into
v6from
bug/AND-993_fix_rtl_keyboard_issues
Jun 3, 2026
Merged

Fix input and message text rendering when using RTL keyboard with LTR device locale#6487
aleksandar-apostolov merged 1 commit into
v6from
bug/AND-993_fix_rtl_keyboard_issues

Conversation

@VelikovPetar
Copy link
Copy Markdown
Contributor

@VelikovPetar VelikovPetar commented Jun 3, 2026

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 a LayoutDirection from the content of the input field by scanning for the first strong directional character (contentLayoutDirection). The inner Row (leading content + text field + trailing content) is wrapped in a CompositionLocalProvider that overrides LocalLayoutDirection with the resolved direction. Empty / neutral input falls back to the device locale's layout direction.
  • MessageTheme.kttextStyle and quotedTextStyle now set textDirection = TextDirection.Content, so message bubbles render in the direction of the text content rather than the locale's default.

🎨 UI Changes

Setup Before After
LTR locale
rtl-keyboard-before.mp4
rtl-keyboard-after.mp4
RTL locale
rtl-keyboard-rtl-global-before.mp4
rtl-keyboard-rtl-global-after.mp4

Testing

  • Set the device locale to English (LTR).
  • Open a channel in the Compose sample app and type Arabic/Hebrew characters in the composer — the input field, cursor, and trailing icons should flip to RTL.
  • Clear the field — the composer should return to the device locale's direction.
  • Send messages containing RTL, LTR, and mixed content — each bubble should render with the direction of its own text.
  • Repeat with the device locale set to Arabic (RTL) to confirm the default fallback still works for empty input.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced bidirectional text (RTL/LTR) handling in message input and display. Text direction is now intelligently determined by message content, improving support for mixed-language messages.

Co-Authored-By: Claude <noreply@anthropic.com>
@VelikovPetar VelikovPetar added the pr:bug Bug fix label Jun 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled (or ignored for dependabot PRs).

🎉 Great job! This PR is ready for review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.26 MB 5.30 MB 0.04 MB 🟢
stream-chat-android-offline 5.49 MB 5.52 MB 0.03 MB 🟢
stream-chat-android-ui-components 10.64 MB 10.72 MB 0.07 MB 🟢
stream-chat-android-compose 12.87 MB 12.91 MB 0.05 MB 🟢

@VelikovPetar VelikovPetar changed the title Fix RTL layout direction in message composer and message text Fix input and message text rendering when using RTL keyboard with LTR device locale Jun 3, 2026
@VelikovPetar VelikovPetar marked this pull request as ready for review June 3, 2026 08:50
@VelikovPetar VelikovPetar requested a review from a team as a code owner June 3, 2026 08:50
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 3, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
63.9% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cff9f271-64e4-4b59-9371-65e42447aff1

📥 Commits

Reviewing files that changed from the base of the PR and between 748080b and d889ec6.

📒 Files selected for processing (2)
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/composer/MessageInput.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/MessageTheme.kt

Walkthrough

The 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.

Changes

Bidirectional Text Support in Message Composer

Layer / File(s) Summary
Content direction detection helper
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/composer/MessageInput.kt
String.contentLayoutDirection(default: LayoutDirection) iterates through characters, detects the first strong directional character (LTR/RTL and embedded/override Unicode variants), and returns the matching Compose LayoutDirection or the provided default.
Message input direction override
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/composer/MessageInput.kt
MessageInput reads LocalLayoutDirection, computes a remembered contentLayoutDirection from the current input value using the helper, and wraps the InputField decorationBox with CompositionLocalProvider(LocalLayoutDirection provides contentLayoutDirection) to apply direction-aware rendering to leading/trailing slots and the text field. Imports updated and method suppressed for length.
Message theme text direction configuration
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/MessageTheme.kt
MessageTheme imports TextDirection and sets textDirection = TextDirection.Content on the default message textStyle and the deprecated quotedTextStyle to enable automatic BiDi handling in message rendering.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

A rabbit's hop from left to right, 🐰
Now flows with text of any might,
BiDi whispers through the code,
Directional magic on the road!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing RTL keyboard/layout issues with LTR device locale in both the composer and message rendering.
Description check ✅ Passed The description includes all essential sections from the template: Goal, Implementation, UI Changes with videos, and comprehensive Testing instructions with clear setup and verification steps.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bug/AND-993_fix_rtl_keyboard_issues

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.

@aleksandar-apostolov aleksandar-apostolov merged commit 2c3b9f7 into v6 Jun 3, 2026
18 of 20 checks passed
@aleksandar-apostolov aleksandar-apostolov deleted the bug/AND-993_fix_rtl_keyboard_issues branch June 3, 2026 11:21
@stream-public-bot stream-public-bot added the released Included in a release label Jun 4, 2026
@stream-public-bot
Copy link
Copy Markdown
Contributor

🚀 Available in v6.40.0

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

Labels

pr:bug Bug fix released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants