Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[web] ignore pointer events on plain text spans #53694

Merged
merged 1 commit into from
Jul 3, 2024
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
10 changes: 9 additions & 1 deletion lib/web_ui/lib/src/engine/semantics/label_and_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,15 @@ final class SizedSpanRepresentation extends LabelRepresentationBehavior {

// The origin of the coordinate system is the top-left corner of the
// parent element.
..transformOrigin = '0 0 0';
..transformOrigin = '0 0 0'

// The node may be tappable without having a more concrete role set on it,
// such as "button". It will just have a tap handler. This could lead to
// sized span to be chosen as the label representation strategy. However,
// when pointer events land on the span the DOM `target` becomes the span
// rather than the tappable element, and that breaks the debouncing logic
// in `pointer_binding.dart`.
..pointerEvents = 'none';
semanticsObject.element.appendChild(_domText);
}

Expand Down
23 changes: 23 additions & 0 deletions lib/web_ui/test/engine/semantics/semantics_text_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,27 @@ Future<void> testMain() async {

semantics().semanticsEnabled = false;
});

test('The <span> ignores pointer events', () async {
semantics()
..debugOverrideTimestampFunction(() => _testTime)
..semanticsEnabled = true;

final SemanticsTester tester = SemanticsTester(owner());
tester.updateNode(
id: 0,
label: 'Ignore pointer events',
transform: Matrix4.identity().toFloat64(),
rect: const ui.Rect.fromLTRB(0, 0, 100, 50),
);
tester.apply();

expectSemanticsTree(owner(), '''
<sem>
<span style="pointer-events: none">Ignore pointer events</span>
</sem>'''
);

semantics().semanticsEnabled = false;
});
}