Skip to content

Fix selection.modify() to use resolved text direction instead of inline base direction#357

Open
sambandaru wants to merge 1 commit intow3c:gh-pagesfrom
sambandaru:gh-pages
Open

Fix selection.modify() to use resolved text direction instead of inline base direction#357
sambandaru wants to merge 1 commit intow3c:gh-pagesfrom
sambandaru:gh-pages

Conversation

@sambandaru
Copy link
Copy Markdown

@sambandaru sambandaru commented Apr 29, 2026

Steps 7–8 of Selection.modify() use the inline base direction (paragraph-level CSS direction) to map "left"/"right" to forwards/backwards. This is wrong when the caret is inside a bidi run with a different direction.

<p dir="ltr">Hello שלום world</p>

When the caret is inside "שלום" (an RTL run) and the user presses the Right arrow, the current spec maps Right to forwards, and moves the caret visually to the left. This is incorrect.

The spec should instead use the resolved text direction at the caret (rtl), which maps Right to backwards and moves the caret visually to the right.

Fix: Replace "inline base direction" with "resolved text direction at the focus" (bidi embedding level per UAX#9: even = LTR, odd = RTL).

Browser behavior: Firefox and Safari already use resolved text direction. Chromium currently matches the spec text; a fix is in progress. This change aligns the spec with majority interoperable behavior.


Preview | Diff

Comment thread index.html Outdated
Comment thread index.html Outdated
@sambandaru
Copy link
Copy Markdown
Author

@rniwa Could you please review

@rniwa
Copy link
Copy Markdown
Contributor

rniwa commented May 4, 2026

For normative changes, the following tasks have been completed:

@rniwa
Copy link
Copy Markdown
Contributor

rniwa commented May 4, 2026

Please file bugs for each browser and have this discussed at an editing WG meeting.

@sambandaru sambandaru added the Agenda+ Queue this item for discussion at the next WG meeting label May 5, 2026
@sambandaru
Copy link
Copy Markdown
Author

For normative changes, the following tasks have been completed:

@sambandaru
Copy link
Copy Markdown
Author

Please file bugs for each browser and have this discussed at an editing WG meeting.

Ack

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

Labels

Agenda+ Queue this item for discussion at the next WG meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants