Skip to content

Fix RTL message alignment and add RTL regression stories#7821

Closed
sari-devv wants to merge 1 commit intosignalapp:mainfrom
sari-devv:fix/rtl-lang-display
Closed

Fix RTL message alignment and add RTL regression stories#7821
sari-devv wants to merge 1 commit intosignalapp:mainfrom
sari-devv:fix/rtl-lang-display

Conversation

@sari-devv
Copy link
Copy Markdown

First time contributor checklist:

Contributor checklist:

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

Description

Fixes issue #7819:
This PR restores correct Right-To-Left (RTL) message alignment in the conversation view. A previous commit accidentally hardcoded dir="ltr" on the inner message text container, which overrode the dynamic directionality for Arabic and Hebrew messages.

What:

  • Removed hardcoded dir="ltr" from the .module-message__text container in Message.dom.tsx.
  • Updated Storybook createProps to allow i18n overrides.
  • Added MixedRtlAndLtrMessage and DeletedRtl stories to TimelineMessage.dom.stories.tsx.

Why:
The hard-coded dir="ltr" attribute on the message text wrapper forced a Left-To-Right context regardless of the actual message content. Since the container uses text-align: start, this caused RTL messages (like Arabic or Hebrew) to incorrectly align to the left side of the bubble and broke the rendering of bidirectional punctuation.

This attribute was originally added to stabilize the "Delete for everyone" layout icon positioning. However, since those strings are now correctly wrapped in <span dir="auto">, the hard-coded attribute on the parent is no longer necessary and was causing wide-spread RTL regressions.

Technical Details:
OS: MacOS, but the testing was done on Storybook.

  • Removing the hard-coded attribute allows the message text to properly inherit the directionality calculated by the message selectors.
  • Manual Testing: Two stories were added:
  1. MixedRtlAndLtr: Mixes Arabic and English, in a similar way to the image in issue Right To Left (RTL) language (Hebrew) messages are left-aligned instead of right #7819's description, and verified the change. Before and after screenshots are attached.
  2. The DeletedRtl story was added to verify that "Delete for everyone" remains stable in RTL contexts. It dynamically imports Arabic strings from _locales/ar/messages.json and mocks the i18n.getIntl() interface to simulate the production environment's usage of the <I18n> component. This ensures that the layout fix is verified against actual RTL text and character-order rules in automated visual tests.

Before vs After Visual Comparison

Before

Before Deleted before

After

After Deleted after

Fixes issue signalapp#7819

What:
- Removed hardcoded `dir="ltr"` from the `.module-message__text` container
  in `Message.dom.tsx`.
- Updated Storybook `createProps` to allow `i18n` overrides.
- Added `MixedRtlAndLtrMessage` and `DeletedRtl` stories to
  `TimelineMessage.dom.stories.tsx`.

Why:
The hardcoded `dir="ltr"` attribute on the message text wrapper forced a
Left-To-Right context regardless of the actual message content. Since
the container uses `text-align: start`, this caused RTL messages (like
Arabic or Hebrew) to incorrectly align to the left side of the bubble
and broke the rendering of bidirectional punctuation.

This attribute was originally added to stabilize the "Delete for everyone"
layout icon positioning. However, since those strings are now correctly
wrapped in `<span dir="auto">`, the hardcoded attribute on the parent
is no longer necessary and was causing wide-spread RTL regressions.

Technical Details:
- Removing the hardcoded attribute allows the message text to properly
  inherit the directionality calculated by the message selectors.
- The `DeletedRtl` story was added to verify that "Delete for everyone"
  remains stable in RTL contexts. It dynamically imports Arabic strings
  from `_locales/ar/messages.json` and mocks the `i18n.getIntl()`
  interface to simulate the production environment's usage of the
  `<I18n>` component. This ensures that the layout fix is verified
  against actual RTL text and character-order rules in automated
  visual tests.
@nehemiagurl
Copy link
Copy Markdown

so... what are the plans regarding this regression? this bug is now landing in production for many users, greatly reducing usability for anyone of the half a billion RTL language speakers, with switching to the LTR interface not improving the situation...

@nirtz89
Copy link
Copy Markdown

nirtz89 commented Apr 12, 2026

This needs to be pushed ASAP.
Over half a billion users are RTL language speakers.

@ayumi-signal
Copy link
Copy Markdown
Contributor

Thank you for opening the PR and correctly identifying the issue. We ended up fixing just the "ltr" attribute, and will consider adding extra storybook as you've suggested or automated visual tests to detect RTL regressions in the future.

@sari-devv
Copy link
Copy Markdown
Author

My pleasure!

Do I need to close this PR now?

@ayumi-signal
Copy link
Copy Markdown
Contributor

For now I'll close it. If we end up using the storybook updates I'll let you know.

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