Skip to content

Commit ef72481

Browse files
klopez4212fin
andcommitted
Restore accessible section menu button semantics
Co-authored-by: fin <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Signed-off-by: kenny lopez <[email protected]>
1 parent 5594712 commit ef72481

2 files changed

Lines changed: 68 additions & 8 deletions

File tree

‎mobile/lib/features/channels/channels_page/sections.dart‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -588,14 +588,20 @@ class _SectionOptionsButton extends StatelessWidget {
588588
final VoidCallback onPressed;
589589

590590
@override
591-
Widget build(BuildContext context) => Tooltip(
592-
message: tooltip,
593-
child: SizedBox.square(
594-
dimension: 40,
595-
child: InkWell(
596-
onTap: onPressed,
597-
borderRadius: BorderRadius.circular(Radii.full),
598-
child: Align(alignment: Alignment.centerRight, child: icon),
591+
Widget build(BuildContext context) => Semantics(
592+
button: true,
593+
label: tooltip,
594+
onTap: onPressed,
595+
excludeSemantics: true,
596+
child: Tooltip(
597+
message: tooltip,
598+
child: SizedBox.square(
599+
dimension: 40,
600+
child: InkWell(
601+
onTap: onPressed,
602+
borderRadius: BorderRadius.circular(Radii.full),
603+
child: Align(alignment: Alignment.centerRight, child: icon),
604+
),
599605
),
600606
),
601607
);

‎mobile/test/features/channels/channels_page_test.dart‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,60 @@ void main() {
248248
await tester.pumpWidget(const SizedBox());
249249
});
250250

251+
for (final label in ['Channels options', 'Design options']) {
252+
testWidgets('$label exposes a labeled button and tap action', (
253+
tester,
254+
) async {
255+
final semantics = tester.ensureSemantics();
256+
try {
257+
await tester.pumpWidget(
258+
buildTestable(
259+
overrides: [
260+
channelsProvider.overrideWith(() => _FakeNotifier(testChannels)),
261+
channelSectionsProvider.overrideWith(
262+
() => _FakeChannelSectionsNotifier(
263+
const ChannelSectionStore(
264+
sections: [
265+
ChannelSection(
266+
id: 'section-1',
267+
name: 'Design',
268+
icon: '🎨',
269+
order: 0,
270+
),
271+
],
272+
),
273+
),
274+
),
275+
],
276+
),
277+
);
278+
await tester.pumpAndSettle();
279+
final control = find.bySemanticsLabel(label);
280+
expect(control, findsOneWidget);
281+
final node = tester.getSemantics(control);
282+
expect(node.flagsCollection.isButton, isTrue);
283+
expect(
284+
node.getSemanticsData().hasAction(ui.SemanticsAction.tap),
285+
isTrue,
286+
);
287+
node.owner!.performAction(node.id, ui.SemanticsAction.tap);
288+
await tester.pumpAndSettle();
289+
expect(
290+
find.byKey(
291+
ValueKey(
292+
label == 'Channels options'
293+
? 'sort-popover-Channels'
294+
: 'section-popover-section-1',
295+
),
296+
),
297+
findsOneWidget,
298+
);
299+
} finally {
300+
semantics.dispose();
301+
}
302+
});
303+
}
304+
251305
testWidgets('section ellipsis aligns with temporary channel icon', (
252306
tester,
253307
) async {

0 commit comments

Comments
 (0)