Repository navigation
Description
Current behavior π
On Skia Desktop/macOS, opening and closing a control's default context flyout (TextCommandBarFlyout, e.g. right-click on a TextBox) permanently removes the control's own accessibility element β and its entire internal accessibility subtree β from the native accessibility tree exposed to VoiceOver/AX clients. The control is still visible and fully usable, but to any AX client it has vanished: accessibilityChildren no longer contains it, and nothing later rebuilds the tree, so it stays broken for the rest of the window's lifetime.
A verbose native trace of the macOS accessibility bridge (UNO_A11Y_VERBOSE=1, Debug build) shows the exact sequence for a single TextBox with AcceptsReturn="True":
added element handle=4362385560 role=textarea label=lorem parent=4362385480 // the TextBox's own AX element
added element handle=5552949632 ... parent=4362385560 // + 13 more legitimate descendants (its internal ScrollViewer/scrollbars)
...
added element handle=5767317152 role=dialog label=Popup parent=4362369456 // the ContextFlyout's own Popup/dialog wrapper
added element handle=5767319664 role=region ... parent=5767317152
added element handle=5767644432 ... parent=5767319664
added element handle=5767699808 ... parent=5767690120 // <-- parent handle 5767690120 was NEVER added to the context
... // (dozens more descendants of 5767699808)
removed element handle=5767317152 (and 2 descendants) // Popup wrapper removed correctly on close
removed element handle=4362385560 (and 14 descendants) // <-- the TextBox's own AX element is removed!
handle=5767690120 is used as a parentHandle at uno_accessibility_add_element but never appears as an added element anywhere before it β the lookup for it fails. After that point the TextBox (and the rest of the real content) is gone from accessibilityChildren.
Expected behavior π―
Opening and closing a context menu/flyout must not affect the accessibility exposure of the control it was opened on (or of any other unrelated content). This matches WinUI, where a TextCommandBarFlyout opening/closing on a TextBox has no effect on the TextBox's own UIA/AX representation (verified by source inspection of FlyoutBase_partial.cpp's light-dismiss/close teardown, which only tears down the flyout's own presenter β not the placement target).
How to reproduce it (as minimally and precisely as possible) π¬
Minimal runtime-test repro (Skia Desktop/macOS), using the native accessibilityChildren Objective-C selector in-process so it isn't affected by AX-client sandboxing:
var textBox = new TextBox { Text = "lorem\nipsum", AcceptsReturn = true };
window.Content = textBox;
window.Activate();
// ... wait for load/idle ...
// First AX client query builds the native tree (objc_msgSend(windowHandle, "accessibilityChildren")).
// FindByRole(windowHandle, "AXTextArea") now finds the TextBox - OK.
var flyout = textBox.ContextFlyout; // default TextCommandBarFlyout
flyout.ShowAt(textBox);
// ... wait for idle ...
flyout.Hide();
// ... wait for idle ...
// FindByRole(windowHandle, "AXTextArea") now returns null: the TextBox is gone.This fails on the very first attempt, every time (verified with UITEST_RUNTIME_TESTS_ITERATIONS=10, UITEST_RUNTIME_TESTS_ATTEMPTS=1: "Failed on iteration 1 of 10").
Manual repro in the SamplesApp: open sample TextBox/TextBox_IsReadOnly_AcceptsReturn, right-click the TextBox to open its context menu, dismiss it (Esc or click elsewhere), then inspect the window's AX tree (e.g. via Accessibility Inspector or AXUIElementCopyAttributeValue on kAXChildrenAttribute/kAXWindowsAttribute) β the TextBox and the rest of the page content are gone; only the title bar remains. The same thing happens after the SamplesApp's reload (β») replaces the current sample's content.
Workaround π οΈ
None found. The window must be closed and reopened to restore accessibility (a fresh window gets a fresh tree).
Affected platforms π±π»π₯οΈ
- Desktop (macOS)
Renderer π¨
- Skia
Uno.Sdk version (and other relevant versions) π¦
Verified on master @ e98c0dcdc3 (includes #23924), net10.0-desktop, macOS, Xcode 26.5.
IDE version π§βπ»
dotnet CLI
Anything else we need to know? π¬
Root cause is in the native accessibility bridge:
src/Uno.UI.Runtime.MacOS/UnoNativeMac/UnoNativeMac/UNOAccessibility.m,uno_accessibility_add_element(around line 1155): whenparentHandle != 0but the parent lookup (findElement) fails β as happens for handle5767690120in the trace above, which is never itself added β the function falls into theelsebranch and doescontext.rootElement = element;, silently promoting the orphaned element to be the new root of the whole accessibility tree, instead of keeping (or at least not losing) the real root. From that point,uno_accessibility_get_root_children(and therefore the window'saccessibilityChildren, seeUNOWindow.maround line 1670-1679) returns only that orphaned subtree β the real content, including theTextBox, becomes unreachable even though itsUNOAccessibilityElementobjects and parent/child links are still intact in memory.uno_accessibility_remove_element(around line 1209) subsequently nilscontext.rootElementwhenever the removed element happens to be the current root (line ~1244), which is how the tree ends up completely empty (not just missing one subtree) once the orphaned root's own subtree is later torn down.
I have not pinned down which managed call site passes the never-registered parentHandle (5767690120) when the TextCommandBarFlyout/MenuFlyoutPresenter opens β most likely something in src/Uno.UI.Runtime.MacOS/Accessibility/MacOSAccessibility.cs (OnChildAdded/AddAccessibilityElement/BuildAccessibilityTreeRecursive) adding a flyout-presenter descendant before its own parent has been registered, during the popup/overlay-layer insertion. That ordering bug is the trigger; the native "silently become root on lookup failure" fallback is what turns it into total tree loss. Either side (fixing the ordering so a parent is always registered first, and/or making the native fallback refuse to overwrite an existing rootElement/attach as a loose child instead) should resolve this.
Confirmed via runtime execution (in-process native accessibilityChildren queries through objc_msgSend, not out-of-process AXUIElement probing, which was unreliable in the sandboxed environment used to investigate this), not just code inspection.
Activity
MartinZikmund commentedon Oct 11, 2026
A much more common trigger: focusing a non-empty
TextBox. No flyout needed.Minimal runtime-test repro (Skia Desktop/macOS,
master@ 951b7b4):This fails on the first attempt every time. The control case (same test, empty
TextBox) does not reproduce it, so focus alone isn't the trigger β showing theDeleteButtonis.A
UNO_A11Y_VERBOSE=1Debug-build trace of the focus call shows the exact same native mechanism as described above, just reached through a different managed path:parentHandle6206570264for the newly added element was never itself added to this context βfindElementfails inuno_accessibility_add_element(UNOAccessibility.m#L1155-L1207), so it falls into theelsebranch and doescontext.rootElement = element;β promoting the orphan to root, exactly as in the flyout case. The real content (19 descendants) is torn down right after, then the orphaned root itself is torn down, anduno_accessibility_remove_element'scontext.rootElement = nil(UNOAccessibility.m#L1209-L1254) fires for it too, leaving the whole tree empty β matching the symptom here.So this looks like the same native fallback, reached by a second, much more common managed trigger: focusing any
TextBoxthat has text, at any point after the AX tree exists, permanently kills the window's accessibility β no context menu required, just Tab or click into the field. I haven't pinned down the exact call inMacOSAccessibility.csthat adds theDeleteButton(or one of its descendants) with the unregistered parent handle; it's likely the sameOnChildAdded/AddAccessibilityElementordering issue already suspected above, just hit via aVisibilitychange on an already-templated child instead of a popup/overlay insertion.