Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

RTL issue in message display

Open gitd3v opened this issue 1 year ago • 7 comments

Description:

after upgrade to 5.0.1, all messages typed in RTL and have mixed persian/english words does not show correctly in desktop app or browser, mobile app is not affected setting "Use legacy message template", temporarily fixes the issue.

Expected behavior:

show messages correctly Screenshot_20220806_094400

Actual behavior:

words is not in the right places Screenshot_20220806_094255

Server Setup Information:

  • Version of Rocket.Chat Server: 5.0.1

Client Setup Information

  • Desktop App or Browser Version: latest
  • Operating System: linux

gitd3v avatar Aug 06 '22 05:08 gitd3v

Same issue here. If I manipulate the DIV wrapping the text by adding dir="auto" to the div tag - Electron gets it right. It even aligns the text to right.

Without it, here is a demo of what is happening

While typing text: image After sending it image

In this example, and also gitd3v's we have right-to-left text followed by English which is left-to-right and then again rtl text. Note how the phrase components are flipped when displayed. In my example the text I wrote was saying "I have one apple" and the display says "apple one I have". PS: If the user was Yoda, that would have been a feature :-)

isaacvonaaron avatar Aug 14 '22 11:08 isaacvonaaron

I created a temporary hack Admin-> Settings -> Layout -> Custom Script for Logged In Users

window.setInterval(
  function() { 
    $("div.rcx-message-container[dir!='auto'],div.rcx-message-body[dir!='auto']").attr('dir', 'auto'); 
  },
  1000
);

Edit - The same hack but without using intervals

var rtlSetFunction = function() {
  window.setTimeout( function() {
    	$("div.rcx-message-container[dir!='auto'],div.rcx-message-body[dir!='auto']").attr('dir', 'auto'); 
    }, 100);
  window.setTimeout( function() {
    	$("div.rcx-message-container[dir!='auto'],div.rcx-message-body[dir!='auto']").attr('dir', 'auto'); 
    }, 1000);
  window.setTimeout( function() {
    	$("div.rcx-message-container[dir!='auto'],div.rcx-message-body[dir!='auto']").attr('dir', 'auto'); 
    }, 10000);
};

document.body.addEventListener('click', rtlSetFunction, true); 
document.body.addEventListener('keyup', rtlSetFunction, true); 
rtlSetFunction();


isaacvonaaron avatar Aug 14 '22 14:08 isaacvonaaron

In 5.0.3 still, the problem exist I had to activate legacy mode

bahmanjafari avatar Sep 07 '22 10:09 bahmanjafari

Thanks, @isaacvonaaron

I created an optimized way using Mutation Observer

Custom Script:


function setAutoDir(){
    $("div.rcx-message-container[dir!='auto'],div.rcx-message-body[dir!='auto']").attr('dir', 'auto'); 
    $("textarea.rc-message-box__textarea[dir!='auto']").attr('dir', 'auto'); 
}
setAutoDir();
var elementCount = $('.rcx-message-body').length;
var observer = new MutationObserver(function(mutations) {
   var newCount = $('.rcx-message-body').length;
   if (newCount != elementCount) {
        elementCount = newCount;
        setAutoDir();
    }
});
observer.observe(document, {attributes: false, childList: true, characterData: false, subtree:true});

This will set dir=auto for messages and input box.


If you want to keep messages in left and just fixing RTL issue, add this

Custom CSS:

.rcx-message-body {
  text-align: left;
}

pouyadarabi avatar Oct 11 '22 12:10 pouyadarabi

Same issue on 3.8.12 on Linux

I think this and https://github.com/RocketChat/Rocket.Chat/issues/26857 are issues related to https://github.com/RocketChat/Rocket.Chat.Electron project though, will open an issue there, mentioning these issues here

molaeiali avatar Oct 11 '22 19:10 molaeiali

Same issue on 3.8.12 on Linux

I think this and #26857 are issues related to https://github.com/RocketChat/Rocket.Chat.Electron project though, will open an issue there, mentioning these issues here

Just to tell you that this is a server issue and not an Electron one, that's why I closed the issue there. Ok? We are aware of this already @debdutdeb ?

jeanfbrito avatar Oct 11 '22 20:10 jeanfbrito

Thanks, @isaacvonaaron, and @pouyadarabi for the workarounds. It works fine. Is there a plan to include this fix in upcoming releases?

ahmadidev avatar Nov 27 '22 07:11 ahmadidev

Hi there, thanks for the contribution! 🚀 💯

Sorry, this error does not happen on the latest and maintained releases.

image

Rocket.Chat  provides support for, at least, 3 months for each release and 6 months to the latest releases of each major version

I would suggest you update your Rocket.Chat version to the latest stable version, which you can find in Releases Page and, check it HERE the table with versions and End of Life dates.


Questions? Help needed? Feature Requests?

hugocostadev avatar Apr 06 '23 11:04 hugocostadev