Skip to content

fix(super-editor): correct cursor movement direction in RTL paragraphs (SD-2390)#2590

Merged
caio-pizzol merged 3 commits intomainfrom
caio/sd-2390-fix-rtl-cursor-movement-in-presentation-mode
Mar 28, 2026
Merged

fix(super-editor): correct cursor movement direction in RTL paragraphs (SD-2390)#2590
caio-pizzol merged 3 commits intomainfrom
caio/sd-2390-fix-rtl-cursor-movement-in-presentation-mode

Conversation

@caio-pizzol
Copy link
Copy Markdown
Contributor

Set dir="rtl" on the hidden ProseMirror editor's paragraph DOM elements when paragraphProperties.rightToLeft is true. Without this, the browser's native bidi cursor handling treated all text as LTR, causing ArrowLeft to move the cursor visually right and ArrowRight visually left in Arabic text.

Also fix resolvePositionAtGoalX binary search for vertical navigation (up/down arrows) to invert search direction in RTL paragraphs where X coordinates decrease with increasing PM positions.

@linear
Copy link
Copy Markdown

linear bot commented Mar 27, 2026

@caio-pizzol caio-pizzol self-assigned this Mar 27, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 712dc822d8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Set dir="rtl" on the hidden ProseMirror editor's paragraph DOM elements
when paragraphProperties.rightToLeft is true. Without this, the browser's
native bidi cursor handling treated all text as LTR, causing ArrowLeft to
move the cursor visually right and ArrowRight visually left in Arabic text.

Also fix resolvePositionAtGoalX binary search for vertical navigation
(up/down arrows) to invert search direction in RTL paragraphs where X
coordinates decrease with increasing PM positions.

SD-2390
Read RTL direction from the visual DOM element (set by DomPainter using
resolved style properties) instead of calling doc.resolve(pmStart) inside
the binary search helper. This fixes two review findings:

1. Eliminates RangeError crash when pmStart is stale (layout-derived
   positions can lag the current document after edits)
2. Correctly detects style-inherited RTL direction (not just inline
   paragraphProperties.rightToLeft)

Also consolidates the duplicated makeRtlEditor test helper into the
existing makeEditor, since isRtl is now a simple boolean parameter.
@caio-pizzol caio-pizzol force-pushed the caio/sd-2390-fix-rtl-cursor-movement-in-presentation-mode branch 2 times, most recently from 4786f2a to 080474a Compare March 28, 2026 09:44
…ment

Add Playwright behavior test that verifies ArrowLeft/ArrowRight move the
cursor in the correct visual direction in RTL paragraphs (and regression
test for LTR). Add visual regression test that screenshots cursor position
after arrow navigation in an RTL document.

Both use the existing rtl-mixed-bidi.docx fixture.

SD-2390
@caio-pizzol caio-pizzol force-pushed the caio/sd-2390-fix-rtl-cursor-movement-in-presentation-mode branch from 080474a to 3e27493 Compare March 28, 2026 09:48
@caio-pizzol caio-pizzol merged commit 357e593 into main Mar 28, 2026
49 checks passed
@caio-pizzol caio-pizzol deleted the caio/sd-2390-fix-rtl-cursor-movement-in-presentation-mode branch March 28, 2026 10:07
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Mar 28, 2026

🎉 This PR is included in vscode-ext v1.1.0-next.34

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Mar 28, 2026

🎉 This PR is included in superdoc v1.24.0-next.33

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Mar 28, 2026

🎉 This PR is included in superdoc-cli v0.5.0-next.33

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot bot commented Mar 28, 2026

🎉 This PR is included in superdoc-sdk v1.3.0-next.33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant