Skip to content

Conversation

@flutter-zl
Copy link
Contributor

@flutter-zl flutter-zl commented Nov 19, 2025

This is a reland of #177570, which was reverted in #178744 due to test failures.

The original PR introduced hitTestBehavior to the semantics framework but incorrectly applied opaque behavior to ModalRoute, which blocked platform views from receiving pointer events.

Instead of making the entire modal opaque, we:

  1. Keep ModalRoute without explicit hitTestBehavior (defaults to defer)
  2. Make only the dialog/sheet content opaque (blocks clicks to barrier)
  3. Platform views remain clickable because they're outside the opaque content boundary

Fixes #149001
Original PR: #177570
Revert: #178744

@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: routes Navigator, Router, and related APIs. labels Nov 19, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces hitTestBehavior to the semantics framework, allowing finer control over hit testing for accessibility. The changes correctly apply this new property to modal widgets like BottomSheet and Dialog to make them opaque, and to platform views to make them transparent, fixing a regression from a previous attempt. Overall, the implementation is solid, but I've identified two critical issues in the property merging logic in semantics.dart that could lead to incorrect behavior when merging semantic nodes. The provided fixes should ensure that the hitTestBehavior of the top-most widget correctly takes precedence.

Address Gemini Code Assistant feedback: Make hitTestBehavior merging
consistent with role and inputType by implementing 'first non-defer wins'
pattern in getSemanticsData().

The absorb() method already uses the correct pattern, so only
getSemanticsData() needed to be fixed.
Fix compilation errors by adding required hitTestBehavior parameter
to all 6 SemanticsData constructor calls in matchers_test.dart.

This was missing from the original PR flutter#177570 changes.
@github-actions github-actions bot added the a: tests "flutter test", flutter_test, or one of our tests label Nov 19, 2025
@dkwingsmt dkwingsmt requested a review from chunhtai November 19, 2025 19:32
@flutter-zl flutter-zl removed the request for review from chunhtai November 19, 2025 19:36
Fix 'Dropdown menu includes semantics' test to match the actual
semantics tree where the modal scope and barrier are siblings
(not parent-child) due to the removal of hitTestBehavior.opaque
from ModalRoute.

return Semantics(
role: semanticsRole,
hitTestBehavior: SemanticsHitTestBehavior.opaque,
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of doing this on the dialog widget, should we do it in the DialogRoute instead? it is possible that someone don't use Dialog widget to create content to be sent to showDialog method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestion. Updated.

namesRoute: true,
label: routeLabel,
explicitChildNodes: true,
hitTestBehavior: SemanticsHitTestBehavior.opaque,
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, I think we should add this to the showBottonSheet and showModalBottomSheet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestion. Updated.

@flutter-zl flutter-zl requested a review from chunhtai November 20, 2025 18:20
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

@flutter-zl flutter-zl added this pull request to the merge queue Nov 25, 2025
Merged via the queue into flutter:master with commit 8f3f89f Nov 25, 2025
67 of 69 checks passed
@flutter-zl flutter-zl deleted the dialog_1027_clean branch November 25, 2025 18:46
@Piinks
Copy link
Contributor

Piinks commented Nov 25, 2025

Reverting as this was manually merged during a tree closure.

@Piinks Piinks added the revert Autorevert PR (with "Reason for revert:" comment) label Nov 25, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Nov 25, 2025

A reason for requesting a revert of flutter/flutter/178817 could
not be found or the reason was not properly formatted. Begin a comment with 'Reason for revert:' to tell the bot why
this issue is being reverted.

@auto-submit auto-submit bot removed the revert Autorevert PR (with "Reason for revert:" comment) label Nov 25, 2025
@Piinks
Copy link
Contributor

Piinks commented Nov 25, 2025

Reason for revert: change was landed during tree closure

@Piinks Piinks added the revert Autorevert PR (with "Reason for revert:" comment) label Nov 25, 2025
auto-submit bot pushed a commit that referenced this pull request Nov 25, 2025
@auto-submit auto-submit bot removed the revert Autorevert PR (with "Reason for revert:" comment) label Nov 25, 2025
@chingjun
Copy link
Contributor

Also this PR was merged while Google Testing was still failing. Can you fix the failing tests before attempting to reland this PR? Thanks.

github-merge-queue bot pushed a commit that referenced this pull request Nov 25, 2025
…8817)" (#179100)

<!-- start_original_pr_link -->
Reverts: #178817
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: Piinks
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: change was landed during tree closure
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: flutter-zl
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {chunhtai}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
This is a reland of #177570, which was reverted in #178744 due to test
failures.

The original PR introduced `hitTestBehavior` to the semantics framework
but incorrectly applied `opaque` behavior to `ModalRoute`, which blocked
platform views from receiving pointer events.

Instead of making the entire modal opaque, we:
1. Keep `ModalRoute` without explicit `hitTestBehavior` (defaults to
`defer`)
2. Make only the dialog/sheet content opaque (blocks clicks to barrier)
3. Platform views remain clickable because they're outside the opaque
content boundary

Fixes #149001
Original PR: #177570
Revert: #178744

<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 26, 2025
flutter/flutter@3f553f6...7b98d50

2025-11-26 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Fix for win32 embedder failing to send all alt key downs to the flutter app (#179097)" (flutter/flutter#179136)
2025-11-26 [email protected] Fix for win32 embedder failing to send all alt key downs to the flutter app (flutter/flutter#179097)
2025-11-26 [email protected] Modernize framework lints (flutter/flutter#179089)
2025-11-25 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Add framework-side hitTestBehavior support to Semantics (#178817)" (flutter/flutter#179100)
2025-11-25 [email protected] Add framework-side hitTestBehavior support to Semantics (flutter/flutter#178817)
2025-11-25 [email protected] Roll Packages from e019cf9 to cc3dca6 (1 revision) (flutter/flutter#179081)
2025-11-25 [email protected] Add tooltip windows to the windowing API alongside the window positioning logic (flutter/flutter#177404)
2025-11-25 [email protected] FlutterWindowsView::SendWindowMetrics now reliably sends the display_id (flutter/flutter#179053)
2025-11-25 [email protected] Remove semantics geometry shortcircuit (flutter/flutter#178680)
2025-11-25 [email protected] Add an assert message when OverlayEntry.remove is called twice (flutter/flutter#178163)
2025-11-25 [email protected] Roll Fuchsia Linux SDK from pOO9Jl9HTLsEmks6y... to nzuAxCJGeJbkZCTkr... (flutter/flutter#179066)
2025-11-25 [email protected] Dynamically set MinimumOSVersion in App.framework (flutter/flutter#178253)
2025-11-25 [email protected] Roll Skia from d83c30b090f4 to 925c311f4b37 (2 revisions) (flutter/flutter#179060)
2025-11-25 [email protected] Marks Linux build_android_host_app_with_module_aar to be unflaky (flutter/flutter#174864)
2025-11-25 [email protected] Marks Linux_mokey complex_layout__start_up to be unflaky (flutter/flutter#174865)
2025-11-25 [email protected] Manual Dart SDK roll to 3.11.0-169.0.dev (flutter/flutter#179054)
2025-11-25 [email protected] Bump Dart to 3.9 (flutter/flutter#179041)
2025-11-25 [email protected] Roll Skia from e298c2f93ebf to d83c30b090f4 (2 revisions) (flutter/flutter#179058)
2025-11-24 [email protected] updated licenses_cpp readme (flutter/flutter#178874)
2025-11-24 [email protected] Roll Skia from 43d2020be565 to e298c2f93ebf (5 revisions) (flutter/flutter#179046)
2025-11-24 [email protected] Refactor `_isLabel` method in `stepper.dart` to use `any` for better readablity (flutter/flutter#178909)
2025-11-24 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 5 to 6 in the all-github-actions group (flutter/flutter#179049)
2025-11-24 [email protected] Disposes test restoration manager when accessed by bindings (flutter/flutter#176519)
2025-11-24 [email protected] [ Widget Preview ] Always generate scaffold under `$TMP` (flutter/flutter#179039)
2025-11-24 [email protected] Roll Packages from e67b6be to e019cf9 (9 revisions) (flutter/flutter#179035)
2025-11-24 [email protected] Update CHANGELOG.md for Flutter 3.38.3 (flutter/flutter#178935)
2025-11-24 [email protected] Remove unnecessary `String.valueOf` in `SettingsChannel.java‎` (flutter/flutter#178590)
2025-11-24 [email protected] Roll pub manually, pick up flutter_lints in examples/api (flutter/flutter#179030)
2025-11-24 [email protected] Roll Dart SDK from 24cc9a740bd3 to afca43095efa (1 revision) (flutter/flutter#179019)
2025-11-24 [email protected] Pass EXCLUDED_ARCHS from Xcode project to xcodebuild for macOS builds (flutter/flutter#176948)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter-zl added a commit to flutter-zl/flutter that referenced this pull request Dec 2, 2025
This is a reland of flutter#177570, which was reverted in flutter#178744 due to test
failures.

The original PR introduced `hitTestBehavior` to the semantics framework
but incorrectly applied `opaque` behavior to `ModalRoute`, which blocked
platform views from receiving pointer events.

Instead of making the entire modal opaque, we:
1. Keep `ModalRoute` without explicit `hitTestBehavior` (defaults to
`defer`)
2. Make only the dialog/sheet content opaque (blocks clicks to barrier)
3. Platform views remain clickable because they're outside the opaque
content boundary

Fixes flutter#149001
Original PR: flutter#177570
Revert: flutter#178744
mboetger pushed a commit to mboetger/flutter that referenced this pull request Dec 2, 2025
This is a reland of flutter#177570, which was reverted in flutter#178744 due to test
failures.

The original PR introduced `hitTestBehavior` to the semantics framework
but incorrectly applied `opaque` behavior to `ModalRoute`, which blocked
platform views from receiving pointer events.

Instead of making the entire modal opaque, we:
1. Keep `ModalRoute` without explicit `hitTestBehavior` (defaults to
`defer`)
2. Make only the dialog/sheet content opaque (blocks clicks to barrier)
3. Platform views remain clickable because they're outside the opaque
content boundary

Fixes flutter#149001
Original PR: flutter#177570
Revert: flutter#178744
mboetger pushed a commit to mboetger/flutter that referenced this pull request Dec 2, 2025
…tter#178817)" (flutter#179100)

<!-- start_original_pr_link -->
Reverts: flutter#178817
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: Piinks
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: change was landed during tree closure
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: flutter-zl
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {chunhtai}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
This is a reland of flutter#177570, which was reverted in flutter#178744 due to test
failures.

The original PR introduced `hitTestBehavior` to the semantics framework
but incorrectly applied `opaque` behavior to `ModalRoute`, which blocked
platform views from receiving pointer events.

Instead of making the entire modal opaque, we:
1. Keep `ModalRoute` without explicit `hitTestBehavior` (defaults to
`defer`)
2. Make only the dialog/sheet content opaque (blocks clicks to barrier)
3. Platform views remain clickable because they're outside the opaque
content boundary

Fixes flutter#149001
Original PR: flutter#177570
Revert: flutter#178744

<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
This is a reland of flutter#177570, which was reverted in flutter#178744 due to test
failures.

The original PR introduced `hitTestBehavior` to the semantics framework
but incorrectly applied `opaque` behavior to `ModalRoute`, which blocked
platform views from receiving pointer events.

Instead of making the entire modal opaque, we:
1. Keep `ModalRoute` without explicit `hitTestBehavior` (defaults to
`defer`)
2. Make only the dialog/sheet content opaque (blocks clicks to barrier)
3. Platform views remain clickable because they're outside the opaque
content boundary

Fixes flutter#149001
Original PR: flutter#177570
Revert: flutter#178744
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…tter#178817)" (flutter#179100)

<!-- start_original_pr_link -->
Reverts: flutter#178817
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: Piinks
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: change was landed during tree closure
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: flutter-zl
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {chunhtai}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
This is a reland of flutter#177570, which was reverted in flutter#178744 due to test
failures.

The original PR introduced `hitTestBehavior` to the semantics framework
but incorrectly applied `opaque` behavior to `ModalRoute`, which blocked
platform views from receiving pointer events.

Instead of making the entire modal opaque, we:
1. Keep `ModalRoute` without explicit `hitTestBehavior` (defaults to
`defer`)
2. Make only the dialog/sheet content opaque (blocks clicks to barrier)
3. Platform views remain clickable because they're outside the opaque
content boundary

Fixes flutter#149001
Original PR: flutter#177570
Revert: flutter#178744

<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Dec 10, 2025
) (#179352)

This is a reland of #178817, which was reverted in #179100 due to test
failures.

The original PR introduced `hitTestBehavior` to the semantics framework
but incorrectly applied `opaque` behavior to `ModalRoute`, which blocked
platform views from receiving pointer events.

Instead of making the entire modal opaque, we:
1. Keep `ModalRoute` without explicit `hitTestBehavior` (defaults to
`defer`)
2. Make only the dialog/sheet content opaque (blocks clicks to barrier)
3. Platform views remain clickable because they're outside the opaque
content boundary

Fixes #149001
Original PR: #177570
Revert: #178744
Mairramer pushed a commit to Mairramer/flutter that referenced this pull request Dec 11, 2025
…ter#178817) (flutter#179352)

This is a reland of flutter#178817, which was reverted in flutter#179100 due to test
failures.

The original PR introduced `hitTestBehavior` to the semantics framework
but incorrectly applied `opaque` behavior to `ModalRoute`, which blocked
platform views from receiving pointer events.

Instead of making the entire modal opaque, we:
1. Keep `ModalRoute` without explicit `hitTestBehavior` (defaults to
`defer`)
2. Make only the dialog/sheet content opaque (blocks clicks to barrier)
3. Platform views remain clickable because they're outside the opaque
content boundary

Fixes flutter#149001
Original PR: flutter#177570
Revert: flutter#178744
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) a: tests "flutter test", flutter_test, or one of our tests f: material design flutter/packages/flutter/material repository. f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Flutter Web] dialogs dismissed prematurely with ensureSemantics

4 participants