Fix misplaced '@' in RTL post meta. #4531
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses #4529
The '@' symbol was placed at the right-side of the user handle, but the correct placement is always at the left-side since the user handle is inherently LTR.
Uses techniques from the specification: https://www.unicode.org/reports/tr9/
Detailed problem description
PostMeta.tsx
combines two separate text-nodes (handle + display name) into one wrapping text node. The BIDI algorithm (see link above) interprets the combined text as mixed LTR and RTL and applies logic as per the specification. As part of this logic, the@
sign is placed on the right side (i.e. "before" in RTL terms) of the user's handle, since@
is a "neutral character", and the combined text is apparently classified as RTL due to the RTL nature of the initial characters of the text (the display name).By telling the algorithm to treat the handle (including the
@
character) as LTR text, this problem is mitigated.Show and tell
Before:
After:
🗒️ Note: Initially, the "After" was still justified towards the profile picture. Upon forking this repo and setting things up again, it was suddenly justified towards the right despite identical code. Now, after rebasing on top of @haileyok's changes, it looks fine again. Hence, I suspect my local environment rather than the code change to have temporarily caused the post meta to be justified to the right.
Testing
✅ Tested on Windows Edge (as shown above).
❌ Don't have the necessary equipment at hand to test on iOS.
❌ Ran into setup problems when trying Android emulator, and didn't spend time trying to set up a Development build.
in other words, it would be helpful to have someone with a fully functioning setup give throw a glance.