Skip to content

Conversation

@QuncCccccc
Copy link
Contributor

@QuncCccccc QuncCccccc commented Apr 22, 2025

Fixes #163576

In updateWith() method, _replaceChildren() is called to generate _children list. _children list is used to generate the hit test order (childrenInHitTestOrder).

In _replaceChildren(), childrenIn**Inverse**PaintOrder is directly assigned to _children, so _children itself follows hit test order. So when we generate the childrenInHitTestOrder, we don't need to reverse the children again.

Screen.Recording.2025-04-21.at.6.41.37.PM.mov

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) f: scrolling Viewports, list views, slivers, etc. labels Apr 22, 2025
@QuncCccccc QuncCccccc requested review from chunhtai and yjbanov April 23, 2025 17:33
@QuncCccccc QuncCccccc marked this pull request as ready for review April 23, 2025 17:33
for (int i = childCount - 1; i >= 0; i -= 1) {
childrenInHitTestOrder[i] = _children![childCount - i - 1].id;
for (int i = 0; i < childCount; i += 1) {
childrenInHitTestOrder[i] = _children![i].id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is surprising, does this mean we always get it wrong?

Copy link
Contributor

@chunhtai chunhtai Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after reading the code more I think the original documentation may be wrong

_children is assigned with the childrenInInversePaintOrder in SemanticsNode.updateWith.

which is called in _buildSemanticsSubtree where the children is the same as _childrenAndElevationAdjustments order and I think by default the _childrenAndElevationAdjustments order is insertion order which will be RenderObject.visitChildForSemantics, which is the paint order.

so the the original code should be correct but just bad name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an update. Talked with @chunhtai offline. It seems the hit test order was incorrect all the time. But previously when we haven't applied OverlayPortal to any widgets, if we push a new route, the items underneath the new route will be thrown away so the hit test only need to handle one "layer" of items and everything is okay. After OverlayPortal is applied to Autocomplete, the items underneath the popup still stay in the tree, and the hit test order starts show problems.

@chunhtai chunhtai self-requested a review April 25, 2025 22:10
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@QuncCccccc QuncCccccc added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 25, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Apr 25, 2025
Merged via the queue into flutter:master with commit d9cbff2 Apr 26, 2025
76 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 26, 2025
@edeetee
Copy link

edeetee commented Apr 26, 2025

Thanks for the semantics fix, the attention to a11y is appreciated.

github-merge-queue bot pushed a commit that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
ash2moon pushed a commit to ash2moon/flutter that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 6, 2025
mboetger pushed a commit to mboetger/flutter that referenced this pull request May 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
romanejaquez pushed a commit to romanejaquez/flutter that referenced this pull request Aug 14, 2025
Fixes flutter#163576

In `updateWith()` method, `_replaceChildren()` is called to generate
`_children` list. `_children` list is used to generate the hit test
order (`childrenInHitTestOrder`).

In `_replaceChildren()`, `childrenIn**Inverse**PaintOrder` is directly
assigned to _children, so _children itself follows hit test order. So
when we generate the `childrenInHitTestOrder`, we don't need to reverse
the children again.



https://github.com/user-attachments/assets/df9d852f-231e-4480-8d8b-10c1d406f120




## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Web] SemanticsBinding.instance.ensureSemantics() is propagating click on overlapping widgets

3 participants