fix: RTL content option no longer flips the whole page (#7900)#7901
Conversation
The pad's RTL content option (rtlIsTrue) is a per-pad setting that should only change the direction of the editor's text contents. The setter in ace2_inner.ts wrote the direction to the top-level `document.documentElement` (`document` there resolves to the main pad page, since the editor iframes are derived from it), which flipped the entire page — toolbar and chrome included. The page direction is owned solely by the UI language (l10n.ts sets it from html10n.getDirection()). Apply the content direction to the inner editor document (`targetDoc.documentElement`) instead, so enabling RTL content leaves the surrounding interface untouched. Adds a frontend test asserting the inner editor flips to RTL while the top-level <html> dir stays ltr. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Review Summary by QodoFix RTL content option flipping entire page chrome
WalkthroughsDescription• Fixed RTL content option flipping entire page instead of just pad contents • Changed rtlistrue setter to apply direction to inner editor document only • Added frontend test verifying inner editor flips while toolbar stays LTR • Prevents per-pad RTL setting from overriding UI language page direction Diagramflowchart LR
A["RTL Content Option"] --> B["ace2_inner.ts rtlistrue setter"]
B --> C["Apply to targetDoc.documentElement"]
C --> D["Inner editor flips to RTL"]
C --> E["Top-level page stays LTR"]
F["UI Language Direction"] --> E
File Changes1. src/static/js/ace2_inner.ts
|
Code Review by Qodo
1.
|
7ea7321 to
a164a63
Compare
…t page-dir assertion (#7900) - Use a frameLocator chain (Playwright auto-waits) instead of page.frame('ace_inner')! which can race with inner-editor readiness. - Don't hardcode dir='ltr' on the top-level <html> (the UI language can legitimately pick rtl). Capture the initial page dir and assert it is unchanged after toggling the pad RTL option — that is the real invariant. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fixes #7900.
Problem
Enabling the pad's RTL content option flips the entire page — the toolbar and surrounding chrome — not just the pad's inner text contents, which is all a per-pad content option should affect.
Root cause
The
rtlistruesetter insrc/static/js/ace2_inner.tswrote the base direction todocument.documentElement. In that filedocumentresolves to the top-level pad page (the editor iframes are derived from it viadocument.getElementsByName("ace_outer")), so toggling RTL content overwrote the whole page'sdirattribute.The page direction is owned solely by the UI language —
src/static/js/l10n.tssetsdocument.documentElement.dir = html10n.getDirection(). The content option must not clobber it.Fix
Apply the content direction to the inner editor document (
targetDoc.documentElement) instead of the top-leveldocument. The inner body already gets the.rtl/.ltrclass; this keeps thedirattribute on the inner<html>where it belongs, so the toolbar/chrome stay governed by the UI language.Test
Added a frontend test (
rtl_url_param.spec.ts) asserting that withrtl=truethe inner editor body flips to RTL while the top-level<html>dirstaysltr. Verified red→green: the test fails against the old code (top-level<html dir="rtl">) and passes with the fix.🤖 Generated with Claude Code