Skip to content

[focusgroup] support writing direction#58056

Merged
chromium-wpt-export-bot merged 1 commit intomasterfrom
chromium-export-cl-7601281
Feb 26, 2026
Merged

[focusgroup] support writing direction#58056
chromium-wpt-export-bot merged 1 commit intomasterfrom
chromium-export-cl-7601281

Conversation

@chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Feb 25, 2026

FocusgroupDirectionForEvent previously hardcoded arrow-to-direction
mappings (e.g. ArrowLeft → BackwardInline) without consulting the
focused element's writing mode or text direction. This meant focusgroup
navigation was incorrect in RTL contexts and vertical writing modes.

Fix by passing the focused element to FocusgroupDirectionForEvent and
using ComputedStyle::GetWritingDirection() to resolve physical arrow
keys to logical directions via WritingDirectionMode. This correctly
handles RTL (inline axis reversed), vertical-rl, vertical-lr,
sideways-rl, and sideways-lr.

Changed FocusgroupDirectionForEvent to take a const Element& param
Reordered HandleArrowKeyboardEvent to obtain the focused element
before resolving direction
Added unit tests for RTL, vertical-rl, and vertical-lr
Added 4 web tests: RTL inline reversal, RTL inline-only axis,
RTL wrapping, and vertical writing mode

Bug: 4021071
Change-Id: I6571c631c6ac3c7c0cf8b8e79da754656d15a3da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7601281
Commit-Queue: Jacques Newman <janewman@microsoft.com>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1590474}

FocusgroupDirectionForEvent previously hardcoded arrow-to-direction
mappings (e.g. ArrowLeft → BackwardInline) without consulting the
focused element's writing mode or text direction. This meant focusgroup
navigation was incorrect in RTL contexts and vertical writing modes.

Fix by passing the focused element to FocusgroupDirectionForEvent and
using ComputedStyle::GetWritingDirection() to resolve physical arrow
keys to logical directions via WritingDirectionMode. This correctly
handles RTL (inline axis reversed), vertical-rl, vertical-lr,
sideways-rl, and sideways-lr.

Changed FocusgroupDirectionForEvent to take a const Element& param
Reordered HandleArrowKeyboardEvent to obtain the focused element
before resolving direction
Added unit tests for RTL, vertical-rl, and vertical-lr
Added 4 web tests: RTL inline reversal, RTL inline-only axis,
RTL wrapping, and vertical writing mode

Bug: 4021071
Change-Id: I6571c631c6ac3c7c0cf8b8e79da754656d15a3da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7601281
Commit-Queue: Jacques Newman <janewman@microsoft.com>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1590474}
Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

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

The review process for this patch is being conducted in the Chromium project.

@chromium-wpt-export-bot chromium-wpt-export-bot merged commit 617484b into master Feb 26, 2026
28 checks passed
@chromium-wpt-export-bot chromium-wpt-export-bot deleted the chromium-export-cl-7601281 branch February 26, 2026 01:03
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.

3 participants