Skip to content

Conversation

@yash-agarwa-l
Copy link
Contributor

@yash-agarwa-l yash-agarwa-l commented Dec 3, 2025

This enables automatic mirroring for directional icons (like arrows and send buttons) in RTL languages.

Previously, icons like chevron_right and send would always point to the right, even in RTL layouts where the flow of the application is right-to-left. This updates the icon generation script to set matchTextDirection: true for these specific icons, ensuring they flip correctly.

This addresses the fourth RTL issue identified by @gnprice in this comment, and fixes #1907.

Changes

  • Updated tools/icons/build-icon-font.js to add matchTextDirection: true for arrow_right, chevron_right, and send.
  • Updated lib/widgets/icons.dart with the regenerated code.

Send Button

State LTR RTL
Before Send Before LTR Send Button Before RTL Send Button
After Send After LTR Send Button (unchanged) After RTL Send Button
Thumbs Up Button (Small Arrow)
State LTR RTL
Before ` > ` Before LTR ` >` Before RTL `>`
` > ` After LTR  ` >` (unchanged) After RTL Thumbs Up Button
More Button (…)
State LTR RTL
Before More Before LTR More Button Before RTL More Button
After More After LTR More Button (unchanged) After RTL More Button

@chrisbobbe
Copy link
Collaborator

(Oops, I didn't mean to close this—accidentally clicked the wrong button.)

@chrisbobbe
Copy link
Collaborator

chrisbobbe commented Dec 4, 2025

Thanks, this looks great!

This looks like a good approach, except I would maybe make a data file for the names of the directional icons. I've pushed two commits with some suggested changes, including that one, so here is the new version of your PR branch:

34d82b0 icons: Add matchTextDirection to directional icons
e295420 icons [nfc]: Refactor named-param generation in build-icon-font
df664c1 icons [nfc]: Put directional-icons data in its own JSON file

Please pull those changes, and if they look good, please squash them into your commit and push the result to the PR.

@chrisbobbe
Copy link
Collaborator

Ah, and also: there are some other icons with arrows that should probably get the same treatment:

  • arrow_left_right
  • (Hmm, maybe just that one—I'd thought there was another, but I guess not.)

And others that aren't arrows but also look like they should flip because they represent text in a directional layout:

  • message_feed
  • topics

@chrisbobbe
Copy link
Collaborator

Could you also add to the instructional comment "To add a new icon […]" in lib/widgets/icons.dart that developers should consider whether the icon is directional, and update that data if so? There's a Material doc you can link to to help the developer make the decision.

@yash-agarwa-l yash-agarwa-l force-pushed the fix-rtl-icon branch 2 times, most recently from ede8007 to a66a0d1 Compare December 4, 2025 22:42
@yash-agarwa-l
Copy link
Contributor Author

Thanks for the refactor commits, @chrisbobbe! I've pulled them in and squashed everything into a single commit.

I also updated directional_icons.json to include message_feed, topics, and arrow_left_right.

I am a bit unsure about arrow_left_right, though—since it depicts a concept (two-way exchange) rather than a specific UI direction, I wonder if it usually stays static? I’ve included it for now to be safe, but I'm happy to remove it if you prefer.

@chrisbobbe
Copy link
Collaborator

Thanks! LGTM; marking for Greg's review.

@chrisbobbe chrisbobbe requested a review from gnprice December 8, 2025 21:58
@chrisbobbe chrisbobbe added the integration review Added by maintainers when PR may be ready for integration label Dec 8, 2025
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks @yash-agarwa-l and @chrisbobbe! Comments below.

I think a good solution for both of these comments would be to treat this file as JS, not JSON: just rename it to a .js name, and use require instead of fs.readFileSync. (The file can still consist of just an array of strings.) Then take the opportunity to add code comments.


// Icons that should flip horizontally in RTL layout.
const directionalIconsFile = path.join(srcDir, 'directional_icons.json');
const directionalIcons = fs.readFileSync(directionalIconsFile);
Copy link
Member

Choose a reason for hiding this comment

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

Huh, does this decode the JSON?

… I think it doesn't, and in fact that has a visible effect: the icon topic gets mirrored, even though it's not in the list, because topics is in the list and its name contains the name "topic". The .includes call below is checking for string inclusion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oop, thanks for the catch!

Comment on lines 1 to 7
[
"arrow_right",
"chevron_right",
"send",
"arrow_left_right",
"message_feed",
"topics"
Copy link
Member

Choose a reason for hiding this comment

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

I think JSON is actually not a good choice for how to encode this. In general, JSON is a bad format to use for any sort of configuration file, or anything else that's going to be maintained over time by humans. (OTOH it's great for transferring data — the job it was designed for.)

The absolutely fatal problem with JSON as a config-file format is that it doesn't permit comments. Here, for example, I'd want to record the reasoning from #2015 (comment) as to why these particular icons are included.

Fixes zulip#1907

We update the icon generation script to automatically set
matchTextDirection: true for icons that imply directionality
(arrow_right, chevron_right, send).

This ensures these icons flip correctly in RTL locales.

We also update the documentation within the generation script to
instruct future contributors on how to handle new directional icons.
@yash-agarwa-l
Copy link
Contributor Author

Thanks! I've switched to a JS file and updated the import logic.

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

Labels

integration review Added by maintainers when PR may be ready for integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RTL: Flip directional icons, like chevron_right and send, in RTL mode

3 participants