Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Correctly align messages in right to left languages #5453

Closed

Conversation

aaronraimist
Copy link
Contributor

@aaronraimist aaronraimist commented Nov 29, 2020

Fixes element-hq/element-web#4771

screenshots


Here's what your changelog entry will look like:

🐛 Bug Fixes

Signed-off-by: Aaron Raimist <aaron@raim.ist>
@t3chguy t3chguy requested a review from a team November 30, 2020 09:41
Copy link
Collaborator

@jryans jryans left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! 😄 Overall, it seems like a good improvement, but I have a few nits on the details.

res/css/views/rooms/_EventTile.scss Outdated Show resolved Hide resolved
@@ -297,6 +297,8 @@ $left-gutter: 64px;

/* De-zalgoing */
.mx_EventTile_body {
text-align: start;
display: block;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than changing mx_EventTile_body elements (which are spans) to display: block, it would be more straightforward to instead make them divs and get this for free.

It would also make sense to me to change mx_EventTile_content elements to divs as well, and remove their display: block style, so we are consistently using div vs. span for their intended meaning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I've changed them over to divs. This mostly works except it breaks the layout for edited messages and /me messages. I'm not sure how to fix this.

screenshots

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, hmm... 😖 Okay, I'll have to think about how we'd want to handle the edited case.

Copy link
Contributor

Choose a reason for hiding this comment

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

what is the issue with edited case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See the screenshot above. The (edited) label is in the wrong place.

Copy link
Contributor

Choose a reason for hiding this comment

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

why not set its display to block and then text-align to start?

Signed-off-by: Aaron Raimist <aaron@raim.ist>
Signed-off-by: Aaron Raimist <aaron@raim.ist>
@ahangarha
Copy link
Contributor

It is needed to add dir="auto" HTML attribute to text placeholders. As far as I know this is not something to be solved effetively using only css.

@aaronraimist
Copy link
Contributor Author

Yes that already exists. The problem is it doesn’t do anything on a span element.

@ahangarha
Copy link
Contributor

Yes that already exists. The problem is it doesn’t do anything on a span element.

I saw it just now on element desktop. I just modified the css with dev tools and the initial result is fine:

.mx_EventTile_body {
    overflow-y: hidden; /* already exists */
    text-align: start;
    display: block;
}

image
I indicated rightly/wrongly aligned lines with some color coding on side. Those two red lines are wrong because I made those message using shift+enter so that they are posed in a single span. This is fine to me as it is manageable and understandable by the user. To me this is fine. I will try to check more complex cases.

@ahangarha
Copy link
Contributor

I have noticed issue with lists which can be resolved using this css:

.markdown-body ol, .markdown-body ul {
    padding-top: 0;
    padding-bottom: 0;
    padding-block-start: 2em;
}

result:

image

@ahangarha
Copy link
Contributor

Quotation fix:

.markdown-body blockquote {
    margin: 0 0 16px;
    padding: 0 15px;
    color: #777;
    /* border-left: 4px solid #ddd; */
    border-inline-start: 4px solid #ddd;
}

before:

image

after:

image

@jryans
Copy link
Collaborator

jryans commented Dec 16, 2020

This is still in my mental queue to think about, but it may take a bit of time / some conversations with Design to work out exactly what we want here.

@ahangarha
Copy link
Contributor

Let me know if I can help.

@jryans jryans self-requested a review January 21, 2021 17:58
@ahangarha
Copy link
Contributor

What is the update? What is preventing this PR to be finalized and merged?

@jryans
Copy link
Collaborator

jryans commented Feb 11, 2021

I still need to work out an approach that handles edited markers and such, and then review that with Design. I haven't had time to do that yet.

@ahangarha
Copy link
Contributor

I still need to work out an approach that handles edited markers and such, and then review that with Design. I haven't had time to do that yet.

May you share what specific issue is there? One (maybe me) might help

@jryans
Copy link
Collaborator

jryans commented Apr 8, 2021

I have unfortunately failed to find the proper time to think about this... 😓 I'll send this back to the general queue in hopes that it might lead to new input here.

@jryans jryans requested review from a team and removed request for jryans April 8, 2021 09:25
@ahangarha
Copy link
Contributor

I have unfortunately failed to find the proper time to think about this... sweat I'll send this back to the general queue in hopes that it might lead to new input here.

May you please share what is there to think? Share the issue so that others might be able to offer some help.

@t3chguy
Copy link
Member

t3chguy commented Apr 12, 2021

@ahangarha its already in a thread above.
#5453 (comment)

@turt2live
Copy link
Member

I'm obviously not familiar with RTL languages, but would it be awful to keep the (edited) bit on the right side of the message text? If that's fine, then we might be able to throw in some flexbox or similar CSS trickery to keep everything lined up (a problem would be multiline messages, but that might be solved with less flexbox and more DOM nesting)

@ahangarha
Copy link
Contributor

@ahangarha its already in a thread above.
#5453 (comment)

If this is the only remaining issue, I will share a solution. Just please list all the remaining issue.

@aaronraimist
Copy link
Contributor Author

@turt2live My understanding is ideally it would be on the left but if we could at least get the message oriented correctly and have the (edited) in the wrong spot that would still be much better than how it currently works.

@jryans
Copy link
Collaborator

jryans commented Apr 15, 2021

At the moment, the app currently (without the change here) shows the "(edited)" label inline with the message text. The "easy" fix to apply RTL to messages also causes them to become a block elements, which moves the "(edited)" label to the next line. I believe the main options to move forward are either:

  • Find a technical solution which preserves the inline placement of the edited label
  • Work with Design team to change the placement of the edited label

@ahangarha
Copy link
Contributor

As far as I see, it can be tweaked to follow bidi algorithm. So, if it is Latin, it remains on left and if gets translated to Persian (or other RTL languages) it moves to right. I think this is the right behavior. If you want to force it to follow the direction of the related text, it is doable but there should be significant change in the layout.

Yet to be frank, this is a minor issue as compared to the situation we (RTL people) face with. I would prefer to get the current improved version and then in next version improve this little minor issue.

Is there any build based on the current modifications so that I can check different scenarios?

@jryans
Copy link
Collaborator

jryans commented Apr 16, 2021

Is there any build based on the current modifications so that I can check different scenarios?

See the deploy preview, you can find the latest link in the Checks section of the PR.

@jryans jryans removed the request for review from a team May 6, 2021 14:01
@ahangarha
Copy link
Contributor

See. I am using Element and I am who uses RTL/LTR both. If anyone is going to suffer it would be me and people like me. And I am fine with this. I don't see it even as a problem.

But that's not true. If it only broke on RTL text it would probably be fine. But your CSS (as well as this PR) move the edited label to the wrong place on all messages, not just RTL.

How much wrong is that place? It is just going to the next line. Is it a big issue? bigger than messing up with mixed RTL/LTR text? I don't think so. And frankly I think we should move that entirely out of that place but that is a different issue.

The fact is that Element has a big issue when it comes to RTL text. We can fix this big issue which would produce a little visual issue for only edited message. I think logic says lets fix the bigger problem now and fix the smaller later. We shouldn't let the smaller issue prevent us from fixing the bigger issue. Am I wrong?

@danialbehzadi
Copy link
Contributor

I completly agree with @ahangarha in this case. Making Element usable in BiDi is more important than a minor visual issue. Anyway I think the current edited sign behaviour is already a bad UX decision and we should find another approach for indicating a message is edited.

@Moork0
Copy link

Moork0 commented Feb 6, 2022

As a RTL user, if this "edited" sign thing is the only reason that prevents me to use my language in messages properly, I really don't care about it.So I totally agree with @ahangarha and @danialbehzadi .

@luixxiul
Copy link
Contributor

luixxiul commented Apr 3, 2022

@ahangarha @danialbehzadi @SeedPuller Since a couple of days I was trying to edit styles to make UI compatible with RTL languages. Please check element-hq/element-web#14520 (comment) for a short video of UI in Hebrew (as UI is not available in languages of Arabic alphabet yet).

@ahangarha
Copy link
Contributor

ahangarha commented Apr 3, 2022 via email

@luixxiul
Copy link
Contributor

luixxiul commented Apr 3, 2022

@ahangarha From my understanding (edited) label breaking can be effectively avoided by setting dir="auto" to the div and changing the margin setting of the (edited) span wrapped with the div. Since I don't want to override this PR, I am going to submit the change with another PR to address element-hq/element-web#14520 partially.

after

Mind the place of the two (edited) labels.

@ahangarha
Copy link
Contributor

By breaking I think they mean it is not inline anymore. To me it is not a problem at all and even if it is, it is not something to block such an important change.

@luixxiul
Copy link
Contributor

luixxiul commented Apr 3, 2022

By breaking I think they mean it is not inline anymore.

It is going to be taken care of 😉
after

@alongls
Copy link
Contributor

alongls commented May 10, 2022

Hello
we are anticipating this improvements and finally to see the Hebrew and Arabic messages in the correct side
thanks.

@MadLittleMods MadLittleMods added Z-Community-PR Issue is solved by a community member's PR T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems labels Jun 2, 2022
@andybalaam
Copy link
Contributor

@luixxiul do you have a PR that supercedes this one, or are you working on this?

@luixxiul
Copy link
Contributor

Right now, not really working on this.

@andybalaam
Copy link
Contributor

This came up in our weekly review as the oldest open non-draft PR! If someone wanted to help it get over the line there would be kudos!

@andybalaam
Copy link
Contributor

This PR adds potentially really valuable functionality to Element Web, but it is currently blocked because it breaks layout in non-RTL contexts (see this comment.

It also need updating to resolve merge conflicts with the latest code.

Is anyone willing to step up to fix the remaining problems so we can merge this PR? If not, I will convert this to draft to indicate that it is not ready, and not under active development.

Lots of people will thank you if you give this a try!

@andybalaam
Copy link
Contributor

Marking this as draft because it needs changes and no-one is actively working on it. If you want to work on it, please do, and mark as Ready for Review when you have address the changes needed. Feel free to discuss what is needed here or in #element-dev:matrix.org Matrix room.

@andybalaam andybalaam marked this pull request as draft July 7, 2022 08:21
@ahangarha
Copy link
Contributor

it needs changes and no-one is actively working on it. If you want to work on it, please do,

If you check the history, there has been people who wanted to help. There are many questions about the importance of the break and almost there is no answer to it. A big bug is not being fixed because it introduces another much much smaller bug.

I would suggest to set a meeting (or some other effective way of communication) to discuss this issue.

@andybalaam
Copy link
Contributor

Hi @ahangarha , thank you for your patience with this!

ahangarha:

There are many questions about the importance of the break and almost there is no answer to it.

My understanding of the situation is that this change introduces a bug.

Quoting aaronraimist:

[this PR] moves the edited label to the wrong place on all messages, not just RTL.

As for how important it is: the answer is "important enough to need fixing before we can merge this change".

I would suggest to set a meeting (or some other effective way of communication) to discuss this issue.

I'm not sure whether that is needed here: if someone fixes the bug (and brings this change up-to-date, which I'm afraid will probably be harder) then we will review it and expect to merge it.

@ahangarha
Copy link
Contributor

Sounds good. Though I think it is more than my current knowledge, but I try to see if I can fix the conflict. I might be able to do it on this weekend. Let's see. At least I try :)

@andybalaam
Copy link
Contributor

Awesome, good luck!

@luixxiul
Copy link
Contributor

luixxiul commented Jul 8, 2022

I made a quick implementation at #9026. Feedback for https://pr9026--matrix-react-sdk.netlify.app/ is appreciated.

dbkr added a commit that referenced this pull request Jul 29, 2024
Inspired by #5453 but
hopefully with the edited marker in the right place.

This is a PoC: types aren't correct and the style needs pulling
out to a class. Plus it would probably need more visual tests added.
If this looks acceptable, I can make these changes.
@dbkr dbkr mentioned this pull request Jul 29, 2024
4 tasks
@dbkr
Copy link
Member

dbkr commented Jul 29, 2024

I've had a go at a version of this PR that keeps the 'edited' marker in the correct place at #12837

@dbkr
Copy link
Member

dbkr commented Jul 31, 2024

#12837 is merged which should fix this! 🤞

@dbkr dbkr closed this Jul 31, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jul 31, 2024
* Fix alignment of RTL messages

Inspired by #5453 but
hopefully with the edited marker in the right place.

This is a PoC: types aren't correct and the style needs pulling
out to a class. Plus it would probably need more visual tests added.
If this looks acceptable, I can make these changes.

* Fix spacing between text and edited annotation

* Update snapshot

* Update more snapshots

* More snapshots

* More more snapshots

* Split out style

* Fix emotes

This will cause them always be right-justified if the display name
is rtl.

* Add playwright test for ltr/rtl message rendering

* Better snapshots

* Await on message sending

* Better waiting, hopefully

* Old snapshot files

* Really hopefully fixed screenshots this time

* Don't include the message action bar in the screenshots
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RTL text should be right-justified