RTL numbered or bullet lists are broken

Real world example: ההנחיות בוויקי לגבי שמות - ישראל (Israel) - OpenStreetMap Community Forum

This section should be numbered, but isn’t - presumably because of bad CSS.

Rendering is a bit different on desktop but still broken.

I’ll try to demonstrate it here too. I don’t know if it depends on forum settings. The following lists are identical in English and Hebrew.

Numbered:

  1. One
  2. Two
    1. Two point one
    2. Two point two
    3. Two point three
  3. Three
    • Three bullet one
    • Three bullet two

Bullet:

  • Bullet one
  • Bullet two
    1. Bullet two number one
    2. Bullet two number two
  • Bullet three
    • Bullet three bullet one
    • Bullet three bullet two

ממוספר:

  1. אחת
  2. שתיים
    1. שתיים נקודה אחת
    2. שתיים נקודה שתיים
    3. שתיים נקודה שלוש
  3. שלוש
    • שלוש פריט אחת
    • שלוש פריט שתיים

פריטים:

  • פריט אחת
  • פריט שתיים
    1. פריט שתיים מספר אחת
    2. פריט שתיים מספר שתיים
  • פריט שלוש
    • פריט שלוש פריט אחת
    • פריט שלוש פריט שתיים

Based on the preview - yup, it’s broken here too. (Edit: added a screenshot below)

1 Like

Suggested fix:

1 Like

Thank you, I hope this gets accepted! I’ve opened a request to apply this patch to the OSM forum directly too: Fix list CSS for RTL languages - 🐞 This forum issues and requests - OpenStreetMap Community Forum

P.S. it seems the OP of this thread was automatically translated to English for me and I can’t find a way to see the original in the mobile UI. What’s going on there? Obviously the issue is no longer visible in this case. Good thing I caught that screenshot earlier!

This may be correct Udi, but I think that rule is just about the preview. some of this might even be a bug in the CSS revereser we use.

@Osama any thoughts on this one?

I am sure we can get this sorted, prioritizing this bug.

The complete rule (see line #92) is:

.cooked,
.d-editor-preview {
  ul,
  ol {
     ...
  }
}

so it applies to .cooked as well (and not only to the preview).

This might be a bug in the reverser, but going forward, start and end properties are the best solution.

Udi

1 Like

Sure, I merged, let me know how it works?

Great!

1 Like

I’m guessing the reverser only gets applied when the UI language is set to Hebrew/Arabic/etc., this is not the case here. RTL text can appear in content even when the UI language is LTR.

As Udi mentioned, it’s often preferable to use -inline-start/end instead of -left/right in style sheets, and not using an error-prone reverser. This would work correctly both for embedded RTL (in post contents) as well as layout RTL (based on selected UI language), with only a single style sheet. You might want to consider migrating to that and retiring rtlcss. But of course, you don’t have to, if there isn’t a real issue to solve.

1 Like

Yeah I agree, we should totally have a solid CSS stylesheet for mixed content, if you come across any other examples that need improving then a PR is totally welcome :hugs:

1 Like

@nat good idea adding the tag. Might want to add it here as well: Wrong -> arrow direction in RTL text contexts (I can’t edit it for some reason). I’ll post some relevant info in that thread in a second (but in short, it’s still a much bigger undertaking than it needs to be, and what I wrote in the OP is still correct).

1 Like

I was playing a bit with this ai artifact to learn about this stuff:

https://meta.discourse.org/discourse-ai/ai-bot/artifacts/248/2

looks like there is a long list of changes and patterns we would need to make to be more RTL friendly.

It is an interesting one to untangle and teach people about. The border stuff is very interesting as well.

1 Like

Glad you find it interesting! I do as well :slight_smile:

I’ll mention that AFAIK -top and -bottom are fine. It’s extremely rare for -block-start and -block-end to not be mapped to them respectively, that should only happen when using Top-To-Bottom layout. I personally have no experience with such layouts at all, and I think the entire website would probably need to be redesigned to accommodate such layouts, so these simple CSS tweaks wouldn’t cut it. But by all means I might be wrong, don’t take my word for it!

Edit: https://stackoverflow.com/questions/510068/how-do-i-make-text-run-top-to-bottom-in-css#53576895

1 Like

The questions that I am thinking about here are:

  • Is it possible to get our CSS into a state where the rtlcss thing no longer needs to run?
  • Is it worth it?
  • Is there a healthy intermediate state?

Funnily enough, this page demonstrates another common issue with mixed directions - scrolling the wrong way:

Unfortunately I never looked into this so I can’t tell you what causes it and how to avoid it.

1 Like

Is it possible - definitely, but it might require a few tweaks in HTML to cooperate with CSS (I can give examples later).

Healthy intermediate state - I would expect that if you change only some things to -inline-start, then rtlcss would ignore them, but keep converting -left. This means you can progressively switch more and more things until rtlcss no longer changes anything. At that point rtlcss can be retired.

Is it worth it - no idea. Consider whether this would make Discourse more stable in RTL, and whether it would be easier to maintain long-term. I really don’t know.

It’s definitely worth it - perhaps required - for CSS applied to user-generated content that can go either way (usually with dir="auto").

Also, while I can’t think of an example off the top of my head, sometimes you really do want to explicitly set the left property of something regardless of the layout direction. In those cases rtlcss would do the wrong thing, unless you’ve made exceptions for that somehow.

1 Like

Here’s an example: Fix display of RTL tag and role values in element info table by jake-low · Pull Request #790 · OSMCha/osmcha-frontend · GitHub

The additional <span> elements inside the <td> elements are necessary to make the table render in the desired layout. In an RTL context, the ::before pseudo-element comes at the right, so if the td itself were RTL then the = sign separating the key and value would instead come at the very end (right side) of the table row.

Basically sometimes you need to nest an extra element to give it a separate direction from its parent. But this might be a good thing depending on your perspective.

2 Likes

I don’t think it would be worth the effort to go all out and update our CSS across core, plugins, and themes just to remove our dependence on rtlcss. A healthy intermediate step could be to use direction-agnostic CSS for areas that contain user-generated content such as posts and bios and for everything else rtlcss will do the job.

3 Likes

This topic was automatically closed after 14 hours. New replies are no longer allowed.