Skip to content

Commit

Permalink
[web] fix clicks on merged semantic nodes (flutter#43620)
Browse files Browse the repository at this point in the history
This should significantly improve the situation described in flutter/flutter#130162.

When the framework merges semantics trees of multiple widgets into a single node, it can expand the tap area of one of the descendants to the size of the combined node as follows:

<img width="865" alt="Screenshot 2023-07-07 at 4 11 30 PM" src="https://github.com/flutter/flutter/assets/211513/50e4f9f2-d36b-4820-93d2-c53714f33b08">

When a screen reader taps on the combined node, the pointer events and the click all land in the center. This produces a stalemate resulting in the user action never producing a tap/click gesture in the framework:

* The web engine, seeing `pointerdown`/`pointerup`, switches to the gesture mode ignores the `click`, believing that the framework will interpret the pointer events as one.
* The framework, seeing pointer events landing outside the checkbox, never reacts to the pointer events.

This PR mostly solves the issue by delaying event sequences starting with pointerdown for up to 200ms. If within those 200ms a click is observed, `SemanticsAction.tap` is sent to the framework. Otherwise, the pointer events are sent to the framework and the DOM `click` event is dropped. The tradeoff is that even when the drag gesture detector is the only one present, there's a 200ms delay before dragging can start. However, it seems to be a better trade-off than missing clicks entirely.
  • Loading branch information
yjbanov authored Aug 3, 2023
1 parent 2d0da33 commit 0c1de9b
Show file tree
Hide file tree
Showing 7 changed files with 750 additions and 115 deletions.
Loading

0 comments on commit 0c1de9b

Please sign in to comment.