Skip to content

Conversation

@flutter-zl
Copy link
Contributor

@flutter-zl flutter-zl commented Oct 27, 2025

Fix premature dialog dismissal on Flutter Web when semantics are enabled by correctly propagating hitTestBehavior through the semantics pipeline and declaring modal routes as opaque to pointer events.

Before change
https://dialog-dismiss-before.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog being dismissed.

After change
https://dialog-dimiss-after.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog not dismissed.

Fixes: #149001
Engine work: #176974

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) f: routes Navigator, Router, and related APIs. labels Oct 27, 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 support to the semantics layer, enabling finer control over how semantic nodes behave during hit testing. The new property is consistently plumbed through SemanticsData, SemanticsProperties, SemanticsNode, and SemanticsConfiguration. A key application of this is in ModalRoute, where hitTestBehavior is set to opaque to correctly block semantics of routes underneath, which is a great improvement for accessibility. The implementation is solid, but I've identified a few areas in packages/flutter/lib/src/semantics/semantics.dart where the new property needs to be handled in related methods like equality checks, copying, and merging to prevent potential bugs.

Comment on lines +1246 to +1294
/// {@macro flutter.semantics.SemanticsProperties.hitTestBehavior}
final ui.SemanticsHitTestBehavior hitTestBehavior;
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The new hitTestBehavior property should be included in the operator== (around line 1331) and hashCode (around line 1364) implementations for SemanticsData to ensure correct equality checks and behavior in collections.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

SemanticsRole role = _role;
Set<String>? controlsNodes = _controlsNodes;
SemanticsValidationResult validationResult = _validationResult;
ui.SemanticsHitTestBehavior hitTestBehavior = _hitTestBehavior;
Copy link
Contributor

Choose a reason for hiding this comment

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

high

In getSemanticsData, when merging descendants, the hitTestBehavior from child nodes is not being merged. This could lead to incorrect semantics. You should add logic to merge hitTestBehavior inside the _visitDescendants loop (around line 3524), similar to how role and inputType are handled. For example:

if (hitTestBehavior == ui.SemanticsHitTestBehavior.defer) {
  hitTestBehavior = node.hitTestBehavior;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment on lines +5973 to +6461
/// {@macro flutter.semantics.SemanticsProperties.hitTestBehavior}
ui.SemanticsHitTestBehavior get hitTestBehavior => _hitTestBehavior;
ui.SemanticsHitTestBehavior _hitTestBehavior = ui.SemanticsHitTestBehavior.defer;
set hitTestBehavior(ui.SemanticsHitTestBehavior value) {
_hitTestBehavior = value;
_hasBeenAnnotated = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

With the addition of the hitTestBehavior property, a few related methods in SemanticsConfiguration need to be updated:

  • The copy() method (around line 6184) is missing .._hitTestBehavior = _hitTestBehavior;. Without this, the property will be lost when a configuration is copied.
  • The absorb() method (around line 6093) does not handle merging _hitTestBehavior from the child configuration. You might want to merge it if the current configuration has the default value.
  • The isCompatibleWith() method (around line 6054) should probably check for conflicting hitTestBehavior values to prevent merging incompatible configurations.

These omissions could lead to incorrect semantics behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

isCompatibleWith is not updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Updated.

@flutter flutter deleted a comment from flutter-dashboard bot Oct 28, 2025
@github-actions github-actions bot added the a: tests "flutter test", flutter_test, or one of our tests label Oct 28, 2025
}

if (_hitTestBehavior == ui.SemanticsHitTestBehavior.defer &&
child._hitTestBehavior != ui.SemanticsHitTestBehavior.defer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The second check is not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Updated.

Comment on lines +5973 to +6461
/// {@macro flutter.semantics.SemanticsProperties.hitTestBehavior}
ui.SemanticsHitTestBehavior get hitTestBehavior => _hitTestBehavior;
ui.SemanticsHitTestBehavior _hitTestBehavior = ui.SemanticsHitTestBehavior.defer;
set hitTestBehavior(ui.SemanticsHitTestBehavior value) {
_hitTestBehavior = value;
_hasBeenAnnotated = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

isCompatibleWith is not updated?

role: role,
controlsNodes: controlsNodes,
validationResult: validationResult,
hitTestBehavior: hitTestBehavior,
Copy link
Contributor

Choose a reason for hiding this comment

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

we may need to force node that sets this to not merge up

For example

Column(
  children: [
     Text('child1'),
     Semantics(hitTestBehavior: .opaque, child: Text('child2')),
     Text('child3'),

  ]
)

If you print the semantics tree you will see the entire column will form a node, and the opaque will merge up to apply to the entire node

There are two way to fix this

  1. force Semantics widget that sets hitTestBehavior to also have container:true
  2. implement SemanticsConfiguration.isCompatible to reject the merge in this case

I think going with (2) makes more sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Updated.

@flutter-zl flutter-zl requested review from a team and jtmcdole as code owners October 31, 2025 04:28
@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems platform-android Android applications specifically platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. engine flutter/engine related. See also e: labels. f: material design flutter/packages/flutter/material repository. f: cupertino flutter/packages/flutter/cupertino repository d: examples Sample code and demos platform-web Web applications specifically a: desktop Running on desktop f: integration_test The flutter/packages/integration_test plugin e: impeller Impeller rendering backend issues and features requests team-android Owned by Android platform team team-ios Owned by iOS platform team labels Oct 31, 2025
@flutter-zl flutter-zl marked this pull request as draft October 31, 2025 04:30
@github-actions github-actions bot removed a: text input Entering text in a text field or keyboard related problems platform-android Android applications specifically labels Oct 31, 2025
@chingjun
Copy link
Contributor

Reason for revert: Broke internal tests.

@chingjun chingjun added the revert Autorevert PR (with "Reason for revert:" comment) label Nov 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 18, 2025
auto-submit bot pushed a commit that referenced this pull request Nov 18, 2025
…et and apply to ModalRoute (#177570)"

This reverts commit 1cc0f49.
@auto-submit auto-submit bot removed the revert Autorevert PR (with "Reason for revert:" comment) label Nov 18, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 18, 2025
…get and apply to ModalRoute (#177570)" (#178744)

<!-- start_original_pr_link -->
Reverts: #177570
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: chingjun
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: Broke internal tests.
<!-- 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:
Fix premature dialog dismissal on Flutter Web when semantics are enabled
by correctly propagating hitTestBehavior through the semantics pipeline
and declaring modal routes as opaque to pointer events.

Before change
https://dialog-dismiss-before.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog being dismissed.

After change
https://dialog-dimiss-after.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog not dismissed.

Fixes: #149001
Engine work: #176974
<!-- 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 18, 2025
flutter/flutter@cc14ef5...cb7b7df

2025-11-18 [email protected] Enable UIScene Migration and update create templates (flutter/flutter#178700)
2025-11-18 Minsuk Jung Fix #160622: change containsWatchConpanion function to detect companion watch apps defined by only the project info file. (flutter/flutter#176832)
2025-11-18 [email protected] Roll Skia from 614e71550fc3 to ca906091e199 (2 revisions) (flutter/flutter#178716)
2025-11-18 [email protected] Revert "[ Tool ] Don't delete `.dart_tool/widget_preview_scaffold` during `flutter clean` (#175664)" (flutter/flutter#178672)
2025-11-18 [email protected] Add missing flutter_lints dev dependencies (flutter/flutter#178105)
2025-11-18 [email protected] Roll Skia from ec2f626cdcad to 614e71550fc3 (3 revisions) (flutter/flutter#178708)
2025-11-18 [email protected] Roll Dart SDK from a8ad764281e3 to 312845b06afc (1 revision) (flutter/flutter#178704)
2025-11-18 [email protected] Roll Skia from d7268f8245f2 to ec2f626cdcad (1 revision) (flutter/flutter#178703)
2025-11-18 [email protected] Refactor SnackBar behavior selection example to use `RadioGroup` (flutter/flutter#178618)
2025-11-18 [email protected] Add framework-side hitTestBehavior support for Semantics widget and apply to ModalRoute (flutter/flutter#177570)
2025-11-18 [email protected] Fix deprecation warning in some API examples using RadioListTile (flutter/flutter#178635)
2025-11-18 [email protected] Roll Skia from 47fd0d9b1044 to d7268f8245f2 (6 revisions) (flutter/flutter#178695)
2025-11-18 [email protected] Roll Dart SDK from cf94632d94a1 to a8ad764281e3 (1 revision) (flutter/flutter#178694)
2025-11-18 [email protected] [fuchsia] Add wrapper for zx_iob_writev (flutter/flutter#178626)
2025-11-17 [email protected] Make a11y `computeChildGeometry` slightly faster (flutter/flutter#177477)
2025-11-17 [email protected] Fix DropdownMenu width when decorationBuilder provides label (flutter/flutter#178465)
2025-11-17 [email protected] Add DropdownMenuFormField.decorationBuilder (flutter/flutter#178640)
2025-11-17 [email protected] Roll Skia from 84c83c0dfb4a to 47fd0d9b1044 (4 revisions) (flutter/flutter#178673)
2025-11-17 [email protected] Small cleanup in `AndroidTouchProcessor.java‎` (flutter/flutter#178574)
2025-11-17 [email protected] Remove unnecessary `final` modifier in `StandardMessageCodec.java‎` (flutter/flutter#178598)

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 Nov 19, 2025
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.
IvoneDjaja pushed a commit to IvoneDjaja/flutter that referenced this pull request Nov 22, 2025
…pply to ModalRoute (flutter#177570)

Fix premature dialog dismissal on Flutter Web when semantics are enabled
by correctly propagating hitTestBehavior through the semantics pipeline
and declaring modal routes as opaque to pointer events.

Before change
https://dialog-dismiss-before.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog being dismissed.

After change
https://dialog-dimiss-after.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog not dismissed.

Fixes: flutter#149001
Engine work: flutter#176974
IvoneDjaja pushed a commit to IvoneDjaja/flutter that referenced this pull request Nov 22, 2025
…get and apply to ModalRoute (flutter#177570)" (flutter#178744)

<!-- start_original_pr_link -->
Reverts: flutter#177570
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: chingjun
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: Broke internal tests.
<!-- 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:
Fix premature dialog dismissal on Flutter Web when semantics are enabled
by correctly propagating hitTestBehavior through the semantics pipeline
and declaring modal routes as opaque to pointer events.

Before change
https://dialog-dismiss-before.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog being dismissed.

After change
https://dialog-dimiss-after.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog not dismissed.

Fixes: flutter#149001
Engine work: flutter#176974
<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Nov 25, 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-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]>
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
…pply to ModalRoute (flutter#177570)

Fix premature dialog dismissal on Flutter Web when semantics are enabled
by correctly propagating hitTestBehavior through the semantics pipeline
and declaring modal routes as opaque to pointer events.

Before change
https://dialog-dismiss-before.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog being dismissed.

After change
https://dialog-dimiss-after.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog not dismissed.

Fixes: flutter#149001
Engine work: flutter#176974
mboetger pushed a commit to mboetger/flutter that referenced this pull request Dec 2, 2025
…get and apply to ModalRoute (flutter#177570)" (flutter#178744)

<!-- start_original_pr_link -->
Reverts: flutter#177570
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: chingjun
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: Broke internal tests.
<!-- 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:
Fix premature dialog dismissal on Flutter Web when semantics are enabled
by correctly propagating hitTestBehavior through the semantics pipeline
and declaring modal routes as opaque to pointer events.

Before change
https://dialog-dismiss-before.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog being dismissed.

After change
https://dialog-dimiss-after.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog not dismissed.

Fixes: flutter#149001
Engine work: flutter#176974
<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <[email protected]>
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
…pply to ModalRoute (flutter#177570)

Fix premature dialog dismissal on Flutter Web when semantics are enabled
by correctly propagating hitTestBehavior through the semantics pipeline
and declaring modal routes as opaque to pointer events.

Before change
https://dialog-dismiss-before.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog being dismissed.

After change
https://dialog-dimiss-after.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog not dismissed.

Fixes: flutter#149001
Engine work: flutter#176974
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…get and apply to ModalRoute (flutter#177570)" (flutter#178744)

<!-- start_original_pr_link -->
Reverts: flutter#177570
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: chingjun
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: Broke internal tests.
<!-- 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:
Fix premature dialog dismissal on Flutter Web when semantics are enabled
by correctly propagating hitTestBehavior through the semantics pipeline
and declaring modal routes as opaque to pointer events.

Before change
https://dialog-dismiss-before.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog being dismissed.

After change
https://dialog-dimiss-after.web.app/

Click on the "Show Dialog" button.
Click anywhere inside the dialog that is not a form field.
Observe the dialog not dismissed.

Fixes: flutter#149001
Engine work: flutter#176974
<!-- 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

3 participants