Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/web_ui/lib/src/engine/semantics/tappable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ class Tappable extends RoleManager {

// Request focus so that the AT shifts a11y focus to this node.
if (semanticsObject.isFlagsDirty && semanticsObject.hasFocus) {
element.focus();
semanticsObject.owner.addOneTimePostUpdateCallback(() {
element.focus();
});
}
}

Expand Down
21 changes: 21 additions & 0 deletions lib/web_ui/test/engine/semantics/semantics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,27 @@ void _testTappable() {

semantics().semanticsEnabled = false;
});

test('focuses on tappable after element has been attached', () async {
semantics()
..debugOverrideTimestampFunction(() => _testTime)
..semanticsEnabled = true;

final SemanticsTester tester = SemanticsTester(semantics());
tester.updateNode(
id: 0,
hasTap: true,
hasEnabledState: true,
isEnabled: true,
isButton: true,
isFocused: true,
rect: const ui.Rect.fromLTRB(0, 0, 100, 50),
);
tester.apply();

expect(flutterViewEmbedder.glassPaneShadow!.activeElement, tester.getSemanticsObject(0).element);
semantics().semanticsEnabled = false;
});
}

void _testImage() {
Expand Down