When switching locale at runtime, modify the body element's LTR/RTL class #27236
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In RTL mode, the
body
element is expected to have artl
CSS class. This patch ensures that the class is added/removed when switching locales dynamically at runtime.Some styles, i.e., the ones that horizontally flip Gridicon arrows, depend on the
body.rtl
class being present.I discovered this bug when working on building our CSS with Webpack.
How to test:
Go to login page and enable the quick language switcher:
Switch language to Hebrew using the Quick Language Switcher and watch the "Back" arrow at the bottom of the login UI:
Actual result (wrong): the arrow points to the left
Expected result (correct): the arrow points to the right, i.e., "back" in RTL mode
Verify that the expected result starts happening after this patch is applied.
Careful observer will notice that the link with the "Back" arrow should be aligned to the right edge in RTL mode, but in reality it's aligned to the left. That's another bug where the section stylesheet is not switched from LTR to RTL in certain scenarios, one of the being using the Quick Language Switcher. Will be solved later.