Skip to content

Only allow setting AXFocused on keyboard-focusable elements on macOS - #22532

Merged
grokys merged 1 commit into
AvaloniaUI:mainfrom
jeff377:fix/macos-axfocused-settable
Oct 20, 2026
Merged

grokys merged 1 commit into
AvaloniaUI:mainfrom
jeff377:fix/macos-axfocused-settable

Conversation

@jeff377

@jeff377 jeff377 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

What does the pull request do?

Gates setAccessibilityFocused: in AvnAccessibilityElement's isAccessibilitySelectorAllowed: on the peer's IsKeyboardFocusable(), like the other setters there.

What is the current behavior?

Every Avalonia automation element reports AXFocused as settable, including text blocks, layout containers and buttons with Focusable="False".

What is the updated/expected behavior with this PR?

AXFocused is settable only when the peer's IsKeyboardFocusable() returns true. It stays readable on every element. Checked with AXUIElementIsAttributeSettable on a TextBox, Button, TextBlock, disabled Button and non-focusable Button in a StackPanel: only the TextBox, the Button and the disabled Button (whose peer still reports it as keyboard-focusable) report true now.

How was the solution implemented (if it's not obvious)?

There's no test for this: XCUITest doesn't expose whether an attribute is settable, so the Appium tests can't observe it. The existing Mac integration tests give the same results locally with and without the change.

Fixed issues

Fixes #22437

@github-actions

Copy link
Copy Markdown

NuGet packages

The packages for this pull request have been published (workflow run):

@MrJul MrJul added os-macos area-accessibility backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Oct 20, 2026

@grokys grokys left a comment

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.

LGTM, thanks for this!

@grokys
grokys added this pull request to the merge queue Oct 20, 2026
Merged via the queue into AvaloniaUI:main with commit fa6d6f0 Oct 20, 2026
12 of 13 checks passed
@MrJul MrJul added backported-12.1.x and removed backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Nov 2, 2026
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.

macOS: every automation element reports AXFocused as settable

3 participants