Skip to content

fix(webkit): enable Tab keyboard navigation on macOS - #42180

Open
Som Samantray (SomSamantray) wants to merge 3 commits into
microsoft:mainfrom
SomSamantray:fix-41808
Open

fix(webkit): enable Tab keyboard navigation on macOS#42180
Som Samantray (SomSamantray) wants to merge 3 commits into
microsoft:mainfrom
SomSamantray:fix-41808

Conversation

@SomSamantray

Copy link
Copy Markdown

Summary

  • Tab keyboard navigation in WebKit on macOS was machine-dependent: with the OS "Keyboard navigation" setting off, Tab skipped buttons and links and only traversed form fields.
  • Playwright now passes -AppleKeyboardUIMode 2 as an NSUserDefaults argument when launching WebKit on macOS, so full keyboard access is always on and Tab traverses all controls regardless of the host setting.
  • The darwin-gated focus test asserts the new deterministic behavior; links remain Option+Tab-only per macOS full keyboard access semantics.

Fixes #41808

Session-settled decisions carried from planning: force AppleKeyboardUIMode=2 for WebKit on macOS via launch args (user-approved, over documenting the workaround).


Compound Engineering

WebKit on macOS reads the "AppleKeyboardUIMode" preference to decide
whether Tab traverses all focusable elements, making Tab behavior
depend on the OS-level "Keyboard navigation" setting. Pass it as an
NSUserDefaults launch argument so Tab always traverses buttons and
inputs regardless of the host setting.

Fixes: microsoft#41808
With full keyboard access forced on macOS WebKit, Tab now moves
between buttons and inputs. Links remain Option+Tab-only, matching
macOS full keyboard access semantics.

References: microsoft#41808
The webkit-wsl channel cannot launch on darwin, so the guard never fires;
the sibling darwin block for proxy args already omits it.

References: microsoft#41808
@SomSamantray

Copy link
Copy Markdown
Author

Note: this fix changes macOS-only WebKit behavior. Could the CQ1 label be applied so the mac test_mac job (webkit) runs the modified page-focus/page-keyboard suites?

@SomSamantray

Copy link
Copy Markdown
Author

Som Samantray (@SomSamantray) please read the following Contributor License Agreement (CLA). If you agree with the CLA, please reply with the following information.

This PR is blocked on the Microsoft Contributor License Agreement. Only the account owner can sign it: reply @microsoft-github-policy-service agree (or agree company="..." for employer submissions). This is a legal sign-off and cannot be performed on the account owner's behalf.

@SomSamantray

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

// starting with '--' as an initial URL, and 'about:blank' must remain the last one.
// See https://github.com/microsoft/playwright/issues/41808.
if (process.platform === 'darwin')
webkitArguments.push('-AppleKeyboardUIMode', '2');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is going to break everyone with the macOS defaults in place (0). But similarly, passing 0 would break teams that aligned on opting into 2.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Webkit on MacOS won't tab between buttons

2 participants