Tooltip 的无障碍遍历顺序已更改
概述
#在无障碍焦点遍历期间,Tooltip.message
会在 Tooltip.child
之后立即被访问。
背景
#Tooltip
widget 通常包装一个交互式 UI 组件(如按钮),并在长按时显示帮助消息。当消息可见时,辅助技术应在按钮之后播报它。
最初,Tooltip
widget 在长按时会将 Tooltip.message
放在 OverlayEntry
上。因此,在语义树中,Tooltip.message
不会在 Tooltip.child
之后立即出现。
迁移指南
#此更改移动了语义树中的 tooltip 消息。如果您的测试期望 tooltip 消息在可见时出现在语义树中的特定位置,您可能会看到无障碍测试失败。请更新任何失败的无障碍测试以适应新的 tooltip 语义顺序。
例如,如果您在测试中构建了以下 widget 树
dart
Directionality(
textDirection: TextDirection.ltr,
child: Overlay(
initialEntries: <OverlayEntry>[
OverlayEntry(
builder: (BuildContext context) {
return ListView(
children: <Widget>[
const Text('before'),
Tooltip(
key: tooltipKey,
showDuration: const Duration(days: 365),
message: 'message',
child: const Text('child'),
),
const Text('after'),
],
);
},
),
],
),
);
当 tooltip 消息可见时,此更改之前的相应语义树应如下所示:
dart
SemanticsNode#0
│
├─SemanticsNode#1
│ │
│ └─SemanticsNode#5
│ │ flags: hasImplicitScrolling
│ │ scrollChildren: 3
│ │
│ ├─SemanticsNode#2
│ │ tags: RenderViewport.twoPane
│ │ label: "before"
│ │ textDirection: ltr
│ │
│ ├─SemanticsNode#3
│ │ tags: RenderViewport.twoPane
│ │ label: "child"
│ │ tooltip: "message"
│ │ textDirection: ltr
│ │
│ └─SemanticsNode#4
│ tags: RenderViewport.twoPane
│ label: "after"
│ textDirection: ltr
│
└─SemanticsNode#6
label: "message"
textDirection: ltr
在此更改后,相同的 widget 树会生成略有不同的语义树,如下所示。节点 #6 成为节点 #3 的子节点,而不是节点 #0 的子节点。
dart
SemanticsNode#0
│
└─SemanticsNode#1
│
└─SemanticsNode#5
│ flags: hasImplicitScrolling
│ scrollChildren: 3
│
├─SemanticsNode#2
│ tags: RenderViewport.twoPane
│ label: "before"
│ textDirection: ltr
│
├─SemanticsNode#3
│ │ tags: RenderViewport.twoPane
│ │ label: "child"
│ │ tooltip: "message"
│ │ textDirection: ltr
│ │
│ └─SemanticsNode#6
│ label: "message"
│ textDirection: ltr
│
└─SemanticsNode#4
tags: RenderViewport.twoPane
label: "after"
textDirection: ltr
时间线
#已在版本中落地:3.16.0-11.0.pre
稳定版本:3.19.0
参考资料
#API 文档
相关 PR