-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fixes an issue where onTapOutside was incorrectly triggered across routes in TapRegion #155297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes an issue where onTapOutside was incorrectly triggered across routes in TapRegion #155297
Conversation
nate-thegrate
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm super impressed with this contribution—it doesn't seem like many people have knowledge & experience with NavigatorObserver and other route/navigation-related APIs.
Case-in-point: when Dart was migrated to sound null safety, nearly every nullable .of(context) method was changed to .maybeOf(context), but it looks like ModalRoute.of(context) never got updated.
My main concern with this PR is that perhaps a developer would want their onTapOutside() to always trigger, or trigger when a non-fullscreen route is pushed, or not trigger at all if it isn't part of the topmost route; having the TapRegionNavigatorObserver baked into the WidgetsApp build() method wouldn't provide that flexibility.
I really appreciate the time you took to read that "zero rebuilds" design doc 😄
I'll be putting up a PR soon that will allow RenderObjectWidgets to respond to dependency updates. This would make it possible to have something like:
class TapRegion extends SingleChildRenderObjectWidget {
// ...
@override
void updateRenderObject(BuildContext context, RenderTapRegion renderObject) {
final ModalRoute<Object?>? route = ModalRoute.of(context);
if (route != null) {
renderObject.onTapOutside = route.isCurrent ? onTapOutside : null;
}
}
}And then we might be able to add a flag or enum to TapRegion so the developer can choose whether it's disabled when the enclosing route is no longer the current one.
Interested to hear your thoughts on this!
I've thought about this before and concluded that while it's a good solution for our current needs, it's not the best. I'm getting more into Flutter and so I sometimes consider more conventional approaches.
I've been looking forward to this for quite some time now.
Once this change is implemented, we can proceed in this manner. I have tried something similar in the past, but since there were no dependency updates to the RenderObjectWidget as you mentioned, the code ended up being less flexible. I think we can wait to approach this in a more efficient way. I would like to emphasize once again that I am still deepening my understanding of how Flutter works and as a result I am not yet able to foresee all the future implications, but I am excited to learn more. |
…cross routes in TapRegion (flutter/flutter#155297)
…cross routes in TapRegion (flutter/flutter#155297)
…cross routes in TapRegion (flutter/flutter#155297)
|
thanks, pretty elegant contribution! When will we see this in stable version? |
…cross routes in TapRegion (flutter/flutter#155297)
Stable releases happen on a quarterly basis, so most likely in a month from now! |
…cross routes in TapRegion (flutter/flutter#155297)
…cross routes in TapRegion (flutter/flutter#155297)
…cross routes in TapRegion (flutter/flutter#155297)
…cross routes in TapRegion (flutter/flutter#155297)
Roll Flutter from 0917e9d to 2d45fb3 (50 revisions) flutter/flutter@0917e9d...2d45fb3 2024-10-09 [email protected] Roll Flutter Engine from 4a97943e0556 to fb0b59d9438b (3 revisions) (flutter/flutter#156487) 2024-10-09 [email protected] Roll Flutter Engine from db0c0b7ca428 to 4a97943e0556 (9 revisions) (flutter/flutter#156478) 2024-10-09 [email protected] Roll Packages from 8fbf4cd to 9d00fb1 (9 revisions) (flutter/flutter#156477) 2024-10-09 [email protected] Started handling duplicate validation layer messages (flutter/flutter#156375) 2024-10-09 [email protected] Roll Flutter Engine from 0e7344ae240d to db0c0b7ca428 (4 revisions) (flutter/flutter#156443) 2024-10-09 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Roll pub packages (#156440)" (flutter/flutter#156473) 2024-10-08 [email protected] Roll Flutter Engine from ea4a00f1c123 to 0e7344ae240d (4 revisions) (flutter/flutter#156435) 2024-10-08 [email protected] Roll pub packages (flutter/flutter#156440) 2024-10-08 [email protected] Roll pub packages (flutter/flutter#156284) 2024-10-08 [email protected] [tool] Update description of where to install platforms in XCode (flutter/flutter#156432) 2024-10-08 [email protected] Roll Flutter Engine from 167a42e50fa2 to ea4a00f1c123 (1 revision) (flutter/flutter#156433) 2024-10-08 [email protected] Normalize `ThemeData.tabBarTheme` (flutter/flutter#156253) 2024-10-08 [email protected] Roll Flutter Engine from 82c1dfcf588c to 167a42e50fa2 (3 revisions) (flutter/flutter#156428) 2024-10-08 [email protected] Update MenuAnchor API examples (flutter/flutter#156404) 2024-10-08 [email protected] Roll Dartdoc to 8.2.0 (flutter/flutter#156426) 2024-10-08 [email protected] Add `bySemanticsIdentifier` finder for finding by identifier (flutter/flutter#155571) 2024-10-08 [email protected] Update `DropdownMenu` tests to remove some dependence on platforms (flutter/flutter#156131) 2024-10-08 [email protected] Roll Packages from bb00d34 to 8fbf4cd (10 revisions) (flutter/flutter#156407) 2024-10-08 [email protected] Roll Flutter Engine from bf21ee76f585 to 82c1dfcf588c (1 revision) (flutter/flutter#156406) 2024-10-08 [email protected] NavigatorPopHandler.onPopWithResult (flutter/flutter#155618) 2024-10-08 [email protected] Roll Flutter Engine from 8ec95fe63f2d to bf21ee76f585 (1 revision) (flutter/flutter#156402) 2024-10-08 [email protected] Roll Flutter Engine from 9306456e2532 to 8ec95fe63f2d (1 revision) (flutter/flutter#156401) 2024-10-08 [email protected] Roll Flutter Engine from 7e8011f3cc8e to 9306456e2532 (1 revision) (flutter/flutter#156398) 2024-10-08 [email protected] Migrator for android 35/16kb page size cmake flags for plugin_ffi (flutter/flutter#156221) 2024-10-08 [email protected] Roll Flutter Engine from 33c1a6a16e81 to 7e8011f3cc8e (5 revisions) (flutter/flutter#156392) 2024-10-08 [email protected] Update `flexible_space_bar_test.dart` tests for Material 3 (flutter/flutter#156226) 2024-10-08 [email protected] Roll Flutter Engine from 012029ee19f3 to 33c1a6a16e81 (1 revision) (flutter/flutter#156390) 2024-10-08 [email protected] Roll Flutter Engine from 5923a8b3e632 to 012029ee19f3 (1 revision) (flutter/flutter#156388) 2024-10-08 [email protected] Roll Flutter Engine from fd1ccdb95e03 to 5923a8b3e632 (1 revision) (flutter/flutter#156386) 2024-10-08 [email protected] Roll Flutter Engine from 07c702f2d79b to fd1ccdb95e03 (1 revision) (flutter/flutter#156384) 2024-10-08 [email protected] Roll Flutter Engine from e096ddb3091e to 07c702f2d79b (2 revisions) (flutter/flutter#156379) 2024-10-08 [email protected] [tool] Emit a deprecation warning for some values of --web-renderer. (flutter/flutter#156376) 2024-10-08 [email protected] Roll Flutter Engine from 427302eafdda to e096ddb3091e (2 revisions) (flutter/flutter#156372) 2024-10-07 [email protected] Roll Flutter Engine from e84e30357ccc to 427302eafdda (3 revisions) (flutter/flutter#156364) 2024-10-07 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 4.2.0 to 4.2.1 (flutter/flutter#156366) 2024-10-07 [email protected] Clarify when `override: no versioning needed` label should be applied (flutter/flutter#156342) 2024-10-07 [email protected] Roll Flutter Engine from 0c9d3f11f098 to e84e30357ccc (3 revisions) (flutter/flutter#156356) 2024-10-07 [email protected] Fixes an issue where onTapOutside was incorrectly triggered across routes in TapRegion (flutter/flutter#155297) 2024-10-07 [email protected] Update 'dump-info' usage for dart2js builds (flutter/flutter#156187) 2024-10-07 [email protected] Roll Flutter Engine from ffacad996f1f to 0c9d3f11f098 (2 revisions) (flutter/flutter#156347) 2024-10-07 [email protected] handle any `RPCError` due to vm service disconnection in `flutter run` (flutter/flutter#156346) 2024-10-07 [email protected] Roll Flutter Engine from 683a14c1f1be to ffacad996f1f (1 revision) (flutter/flutter#156339) 2024-10-07 [email protected] Roll Flutter Engine from 8e46a7670b94 to 683a14c1f1be (1 revision) (flutter/flutter#156323) 2024-10-07 [email protected] Roll Packages from 05bf1d4 to bb00d34 (8 revisions) (flutter/flutter#156322) 2024-10-07 [email protected] Fix `DropdownMenu` with `expandedInsets` always aligned on top (flutter/flutter#156214) 2024-10-07 [email protected] Roll Flutter Engine from a190ab54ce07 to 8e46a7670b94 (2 revisions) (flutter/flutter#156311) ...
…cross routes in TapRegion (flutter/flutter#155297)
…cross routes in TapRegion (flutter/flutter#155297)
…ation state (#169067) Fixes #169061 Expands on #155297 This PR fixes the issue where TapRegion with consumeOutsideTaps enabled would consume taps even after navigating to a different page. ## 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.
…ation state (flutter#169067) Fixes flutter#169061 Expands on flutter#155297 This PR fixes the issue where TapRegion with consumeOutsideTaps enabled would consume taps even after navigating to a different page. ## 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.
…ation state (flutter#169067) Fixes flutter#169061 Expands on flutter#155297 This PR fixes the issue where TapRegion with consumeOutsideTaps enabled would consume taps even after navigating to a different page. ## 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.
…ation state (flutter#169067) Fixes flutter#169061 Expands on flutter#155297 This PR fixes the issue where TapRegion with consumeOutsideTaps enabled would consume taps even after navigating to a different page. ## 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.
…ation state (flutter#169067) Fixes flutter#169061 Expands on flutter#155297 This PR fixes the issue where TapRegion with consumeOutsideTaps enabled would consume taps even after navigating to a different page. ## 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.
…ation state (flutter#169067) Fixes flutter#169061 Expands on flutter#155297 This PR fixes the issue where TapRegion with consumeOutsideTaps enabled would consume taps even after navigating to a different page. ## 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.
Fixes #153093
This PR fixes the issue of onTapOutside being triggered on other routes incorrectly.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.