pachli / pachli-android

The Pachli Android app
https://pachli.app
GNU General Public License v3.0
119 stars 15 forks source link

@usernames should not determine bidi direction #870

Closed NeatNit closed 1 month ago

NeatNit commented 2 months ago

Describe the bug For users in Hebrew, Arabic or Persian (I think) which are written right to left, the @mentions at the start of a reply cause the entire first paragraph to be rendered left to right. This causes it to be less readable.

If this were HTML, I'd suggest you wrap any mention in a bdi tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/bdi (or use CSS which can also do that).

To Reproduce Steps to reproduce the behavior:

  1. Reply to anything
  2. Include the default mention, and write in a RTL language. Finish with a punctuation mark. For example: @whoever שיהיה לך יום טוב.
  3. Post and look at the result

Expected behavior The paragraph should be rendered in RTL, aligned right, and the punctuation mark should be on the left at the end of the text.

Screenshots or video Screenshot_20240806_044530_Pachli

Links https://fosstodon.org/@neatnit/112912082714265949

Versions Pachli 2.7.0, Android 14, OneUI 6.1, Samsung Galaxy S22+.

Affirmation I did not check for other issues, sorry. Feels like the kind of issue that would be resolved soon after it's brought up.

nikclayton commented 2 months ago

Would you be able to do a quick mockup showing what that screenshot should look like if things are working correctly? That'll help me verify any changes are working correctly.

Note to self: https://developer.android.com/reference/android/text/BidiFormatter

NeatNit commented 2 months ago

No need for a mockup, the website does it fine:

Screenshot_20240807_084321_Fennec

NeatNit commented 2 months ago

Oh, I just noticed that the behavior is already (almost) correct in the main timeline (or my timeline with replies), but not when entering the post or its parent.

same comment in timeline showing correct behavior

NeatNit commented 2 months ago

Though, the @ symbol should appear to the left of a username in either case.

Effectively, it seems like it's doing this: @<bdi>username</bdi> {{rest of the message}}

When it should be doing this: <bdi>@username</bdi> {{rest of the message}}

And of course, this should apply to each username mention individually, even in the middle of a post.