Repository navigation
Commit 7ecca28
authored
fix(rtl): use :dir() for rtl styles when the browser supports it (#31744)
Issue number: internal
---------
## What is the current behavior?
The `rtl()` mixin outputs a `:host-context([dir=rtl])` selector for
Chromium alongside a `:dir(rtl)` selector for Firefox and Safari.
`:host-context([dir=rtl])` matches any ancestor with `dir="rtl"`, even
when a closer ancestor sets `dir="ltr"`. In Chromium, an LTR section
inside an RTL page gets the RTL styles from every shadow component that
uses the RTL mixins.
This is visible in the popover position test: in "LTR, Start" in
`popover-position-ios-rtl-Mobile-Chrome-linux.png`, the arrow points
away from its trigger. Firefox and Safari already render it correctly
because they only use `:dir()`.
## What is the new behavior?
- The `:host-context()` selectors are now only output inside `@supports
not selector(:dir(rtl))`, so browsers that support `:dir()` use it
exclusively. `:dir()` follows the nearest ancestor with a `dir`
attribute.
- Chrome 120+ now matches Firefox and Safari. Chrome 89 - 119 keep the
`:host-context()` fallback, so their behavior does not change.
- Updated the Chrome ground truth for `popover/test/position` (ios,
rtl), where the "LTR, Start" arrow now points at its trigger.
## Does this introduce a breaking change?
- [ ] Yes
- [x] No
## Other information
- Only the Chromium output changes. The compiled CSS for 34 component
stylesheets changes by wrapping the existing `:host-context()` rules in
`@supports not selector(:dir(rtl))`, and nothing else. Global
stylesheets are unchanged.
- I ran every component whose CSS changed in Docker. The only screenshot
that changed is the popover one above.
- This fixes the arrow part of FW-7850. The top and bottom `alignment`
issue on that ticket is calculated in JavaScript in `popover/utils.ts`
and is not part of this PR.
Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>1 parent 17326e1 commit 7ecca28
2 files changed
Lines changed: 15 additions & 17 deletions
File tree
- core/src
- components/popover/test/position/popover.e2e.ts-snapshots
- themes
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
261 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
262 | 265 | | |
263 | | - | |
264 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
265 | 270 | | |
266 | 271 | | |
267 | 272 | | |
| |||
272 | 277 | | |
273 | 278 | | |
274 | 279 | | |
275 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
276 | 287 | | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | 288 | | |
291 | 289 | | |
292 | 290 | | |
| |||
0 commit comments