Skip to content

fix(rtl): use :dir() for rtl styles when the browser supports it - #31744

Draft
brandyscarney wants to merge 1 commit into
mainfrom
FW-7850
Draft

brandyscarney wants to merge 1 commit into
mainfrom
FW-7850

Conversation

@brandyscarney

Copy link
Copy Markdown
Member

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
  • 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.

@vercel

vercel Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ionic-framework Ready Ready Preview Nov 12, 2026 7:53pm UTC

Request Review

The rtl mixin output a :host-context([dir=rtl]) selector for Chromium
alongside :dir(rtl). :host-context() matches any ancestor with
dir="rtl", so an LTR section inside an RTL page got the RTL styles in
Chromium, such as a popover arrow pointing away from its trigger.

:host-context() is now only a fallback for browsers without :dir()
support, so Chrome 120+ follows the nearest dir like Firefox and
Safari.

This branch was successfully deployed

1 active deployment
Preview — 3b98571a Deployed Nov 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant