-
-
Notifications
You must be signed in to change notification settings - Fork 830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mechanism for detecting RTL inside components #773
Comments
This article has an interesting solution https://dev.to/madsstoumann/a-quick-guide-to-css-logical-properties-2fce Things we should still fix -
with their Logical CSS equivalent. Perhaps it would be useful to add a warning in the future, for any commit with these keywords? |
This has been implemented in Some components, such as Range and Tab Group, have already been updated to use it. Additional RTL bugs should be filed as new issues so we can track them accordingly. |
Today I discussed this with @AliMD he believes this shouldn't be controlled with localizing package I searched about it and found Too I checked If you( @claviska ) agree with that tell me to apply it to the code. |
It boils down to performance. I explored this extensively for You can read more about this decision here: #419 (comment) TL;DR — it's expensive to do DOM traversal to find the closest element with a Based on feedback from the RFC, we decided the limitation resulting from caring only about We still wanted to support multiple translations, but due to the aforementioned issue, we decided to ignore ancestors and require users to explicitly add the <html lang="en">
<div lang="fr">
<sl-button>Whoops, I'm still in English</sl-button>
</div>
</html> This brings us back to the concept of directionality, which is very similar. In fact, the proposed https://codepen.io/claviska/pen/VwWejBz The problem with We also care about reactivity. If the direction changes at any point, either on As far as I can tell, we wouldn't be able to do this using If you search the source for the following string, you'll see it's used in a number of places: this.localize.dir() Sometimes it's used to toggle a RTL class in a template. Other times it's used to respond to keyboard and mouse events. Calling Based on that, I don't think moving to |
In #768 we talked about the need for detecting RTL outside of CSS. This issue intends to track how we're going to do that.
I recall seeing some clever ways to efficiently detect RTL, one using
matchMedia()
to test for:dir
or something like that. This may be more efficient than DOM traversal.Let's use this issue to explore the best way to do it.
Below are some outstanding issues that can be addressed by this. I'm reluctant to create separate tickets for them until we've established an acceptable solution for detecting RTL from inside a component's logic.
Range tooltip isn't positioned correctly when using RTLfixed in f6d3f79Tab Group's active tab indicator doesn't align correctly when using RTLfixed in 70c97e2The text was updated successfully, but these errors were encountered: