Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[web] fix clicks on merged semantic nodes (flutter#43620)
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