question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider RTL directions with the `placement` option

See original GitHub issue

CSS has something called logical propertied, which introduces block and inline " to control layout through logical, rather than physical, direction and dimension mappings."

Also when I set display: flex to a DOM element it tidies its children elements respecting the direction of writing which can be set with CSS’s direction: rtl or the HTML’s dir=rtl attribute to any tag.

Now I used Floating UI to compute the position of the floating menu that is opened by clicking a button. This floating menu’s placement should be either bottom-end or bottom-start considering the direction of writing which may be RTL. BUT THIS DOESN’T HAPPEN.

image

In the above image, the menu has a placement of bottom-end but with RTL in our perception this is wrong, it is actually bottom-start.

image

With LTR it is just fine 👌.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:19 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
atomikscommented, Feb 10, 2022

A couple of concerns:

  1. {block|inline}-{start|end} is foreign to most devs right now; logical properties are way less intuitive than physical ones.
  2. We can’t specify an alignment. This may mean we need to split this into two separate options.

For example, block-start for English is the top side. But that will just use the center alignment. block-start-start is weird syntax.

top-end right now would be:

side: 'block-start',
align: 'end',

Thinking we should actually forgo start and end and use physical properties by default and make logicalProperties a middleware which enables this behavior?

2reactions
atomikscommented, Feb 11, 2022

Starting with a physical side and then using a logical alignment is really intuitive imo (the current API).

You avoid having to think about the direction of the alignment, for example top-right and right-top describe top-end and right-start in the current API but the latter is less confusing to me. I think handling the alignment with RTL is far more common than needing to handle writing mode directions.

I’m thinking we should support RTL by default and keep the current placement option. Handling writing modes is something the user could do themselves if needed as a middleware, because it really is an advanced use case and requires a big change to the placement options by splitting them into two.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building Multi-Directional Layouts - CSS-Tricks
If the element's computed direction is ltr , the text would be aligned right; and the computed direction would be opposite for the...
Read more >
Structural markup and right-to-left text in HTML - W3C
This article looks at ways of handling text direction for structural markup in HTML, ie. at the document level and for elements like ......
Read more >
Right-to-left (RTL) languages - styling considerations
Some styles need to be optimised for RTL. These are all directional-based styles: Text-align; Padding; Margin; Border; Position; Float. Any unequal styles that ......
Read more >
Right-to-left Styling - RTL Styling 101
An extensive guide on how to style for RTL in CSS.
Read more >
direction - CSS: Cascading Style Sheets - MDN Web Docs
The direction CSS property sets the direction of text, table columns, and horizontal overflow. Use rtl for languages written from right to left ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found