Skip to content

Fix macOS AXLayoutChanged notifications dropped for template-internal peers - #21595

Merged
MrJul merged 3 commits into
masterfrom
fix/macos-ax-layoutchanged-notification
Jun 16, 2026
Merged

Fix macOS AXLayoutChanged notifications dropped for template-internal peers#21595
MrJul merged 3 commits into
masterfrom
fix/macos-ax-layoutchanged-notification

Conversation

@jmacato

@jmacato jmacato commented Jun 16, 2026

Copy link
Copy Markdown
Member

What does the pull request do?

Makes macOS deliver AXLayoutChanged to assistive technologies when a control's children change (e.g. expanding an Expander).

What is the current behavior?

raiseChildrenChanged posts the notification on self, but the peer that changes is usually a template-internal layout container (the Expander's DockPanel root, VisualLayerManager, etc.) whose isAccessibilityElement is NO. AppKit silently drops notifications posted on non-accessibility elements, so AX clients never see the new subtree until they re-navigate.

What is the updated/expected behavior with this PR?

The notification is posted on the changed peer's templated parent (the control that owns the template), which is an accessibility element. Verified with an out-of-process AXObserver on the application element: expanding an Expander raised zero layout notifications before, and arrives after (re-targeted from the DockPanel to the owning Expander).

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

AvnAutomationPeer exposes GetTemplatedParent() (the owning control's peer, resolved from TemplatedParent), and raiseChildrenChanged posts on it, jumping straight past the template's internal containers. Elements with no templated parent (e.g. overlay layers) fall back to walking up to the nearest exposed ancestor.

Breaking changes

None.

@MrJul MrJul added bug os-macos area-accessibility backport-candidate-12.0.x Consider this PR for backporting to 12.0 branch labels Jun 16, 2026
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0066489-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

The changed peer is usually a template-internal layout container that AppKit will not deliver notifications for; post on its templated parent (the owning control), falling back to the nearest exposed ancestor when there is none.
@jmacato
jmacato force-pushed the fix/macos-ax-layoutchanged-notification branch from e8d2860 to b89f8bc Compare June 16, 2026 14:27
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0066505-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul 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!

@MrJul
MrJul enabled auto-merge June 16, 2026 15:52
@MrJul
MrJul added this pull request to the merge queue Jun 16, 2026
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0066515-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

Merged via the queue into master with commit 376a6e2 Jun 16, 2026
11 checks passed
@MrJul
MrJul deleted the fix/macos-ax-layoutchanged-notification branch June 16, 2026 17:33
MrJul pushed a commit to MrJul/Avalonia that referenced this pull request Jun 23, 2026
… peers (AvaloniaUI#21595)

* Post macOS AXLayoutChanged on the changed peer's templated parent

The changed peer is usually a template-internal layout container that AppKit will not deliver notifications for; post on its templated parent (the owning control), falling back to the nearest exposed ancestor when there is none.

* Update with comment
@MrJul MrJul added backported-12.0.x and removed backport-candidate-12.0.x Consider this PR for backporting to 12.0 branch labels Jun 23, 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.

3 participants