Skip to content

Commit e4e41af

Browse files
committed
fix: keep tooltip anchors out of merged semantics nodes
A Tooltip is an OverlayPortal whose overlay content is linked to the anchor by a traversal-parent identifier. IndexedSemantics merges adjacent rows of a ListView into a single node, and the merge drops that identifier instead of combining it, leaving the tooltip node orphaned outside the tree. Windows then rejects the whole accessibility update: Failed to update ui::AXTree, error: N will not be in the tree and is not the new root. Wrapping each anchor in Semantics(container: true) keeps it un-mergeable. This is an engine-side framework bug (flutter/flutter#182444), still unfixed in the pinned engine, so the workaround needs to stay.
1 parent c5740f5 commit e4e41af

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎lib/shared/md3_widgets.dart‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,26 @@ class StatusBarButton extends StatelessWidget {
306306
},
307307
);
308308

309+
// `container: true` keeps this anchor as its own semantics node.
310+
//
311+
// A Tooltip is an OverlayPortal, and its overlay content is linked to the
312+
// anchor by a semantics traversal-parent identifier. When two adjacent
313+
// tooltip anchors get merged into a single node -- which is what
314+
// IndexedSemantics does for every row of a ListView -- the second anchor's
315+
// traversal-parent identifier is dropped instead of merged, leaving its
316+
// overlay content as an orphan that points outside the tree. Windows then
317+
// rejects the whole accessibility update and logs:
318+
// Failed to update ui::AXTree, error: N will not be in the tree and is
319+
// not the new root
320+
// It is an engine-side framework bug (flutter/flutter#182444, still
321+
// unfixed in the pinned engine), and `container: true` is the workaround
322+
// that keeps every anchor un-mergeable. Do not "simplify" this away.
309323
final result = tooltip == null
310324
? child
311-
: Tooltip(message: tooltip!, child: child);
325+
: Tooltip(
326+
message: tooltip!,
327+
child: Semantics(container: true, child: child),
328+
);
312329

313330
if (fixedWidth != null) {
314331
return SizedBox(

‎lib/shared/tabbed_view/tab_header_widget.dart‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,18 @@ class TabHeaderWidget extends StatelessWidget {
140140
overflow: TextOverflow.ellipsis,
141141
);
142142
if (tab.tooltip != null) {
143-
tabText = Tooltip(message: tab.tooltip, child: tabText);
143+
// `container: true` prevents this anchor from being merged into a
144+
// neighbouring tab's semantics node. A Tooltip links its overlay content
145+
// to the anchor with a traversal-parent identifier, and a merge drops
146+
// that identifier instead of combining it, which orphans the tooltip
147+
// node and makes Windows reject the entire accessibility tree update
148+
// ("will not be in the tree and is not the new root"). The tab strip is
149+
// the worst place for this: tabs sit side by side and a partially
150+
// visible one is common. See flutter/flutter#182444.
151+
tabText = Tooltip(
152+
message: tab.tooltip!,
153+
child: Semantics(container: true, child: tabText),
154+
);
144155
}
145156
textAndButtons.add(
146157
Expanded(

0 commit comments

Comments
 (0)