-
Notifications
You must be signed in to change notification settings - Fork 29.7k
SelectionArea's selection should not be cleared on loss of window focus #148067
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
Conversation
78ecd92 to
6277b9c
Compare
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.
is this for someone minimize the windows and resume it?
Also does this work for embedded flutter view?
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.
Yeah this is for that case, or when someone clicks on a different applications window. I'm not too familiar with embedded flutter views and how they tie into the app lifecycle, but it seems at least for Android that a developer has to manually bridge the lifecycle events from their host application to the FlutterView https://docs.flutter.dev/add-to-app/android/add-flutter-view . I think if the lifecycle events are correctly bridged to their FlutterView that this should also work for them.
With regards to an embedded FlutterView in HTML, I used the sample https://github.com/flutter/samples/tree/main/web_embedding/ng-flutter to verify that the FlutterView was correctly receiving lifecycle events. Clicking onto an element in the host web page did not seem to trigger any changes to the app lifecycle. I only observed application lifecycle events triggered when clicking on a new tab, clicking on a different window, or different application outside the browser.
chunhtai
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.
LGTM
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.
maybe mention in which situation the lifecycle would not be resume.
gspencergoog
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.
|
@chunhtai @gspencergoog I managed to track down the google testing issues. Some users modify the Some other things I can think of is exposing some method in the |
80ef35f to
738090d
Compare
In If they do it in |
|
They add listeners in |
|
Ahh. So, could we instead initialize the Since |
|
I'm not sure I follow. If we initialize flutter/packages/flutter_test/lib/src/widget_tester.dart Lines 181 to 183 in a8a9b9b
setUp is called, so inside that method the user already has the correct defaultTargetPlatform for the given test (I think?), then we could initialize the FocusManager before setUp and it would have the correct platform context. That's a bit tricky to do though since the test is run asynchronously, I don't see a place where I could set up the test variant any earlier, unless we change the actual test_api to support running some callback before setUp. What do you think?
From what I understand this is the order of operations for a given test: |
|
Actually, in effect, I guess I'm proposing the same thing that you are in the PR: your I'm a little leery of adding that as a public API, though: I don't see any use for it outside of tests. Maybe mark it |
|
Oh okay I understand. I agree, I am also not so sure about having it as a public API. The analyzer complains about visibleForTesting because it's not technically being used in a test, even though it's in |
|
Yeah, we should really fix the analyzer test to allow |
6aed873 to
d2ea333
Compare
|
Thanks for the suggestion! Done. |
d2ea333 to
fb56a3c
Compare
gspencergoog
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.
Still LGTM
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.
| /// method after it has setup the test variant for a given test, so the | |
| /// this method after it has set up the test variant for a given test, so the |
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.
| /// [FocusManager] can accurately listen to application lifecycle changes if | |
| /// [FocusManager] can accurately listen to application lifecycle changes, if |
…hould also reset focusManager
…ould save it so we can restore it when we rebuild FocusManager to consider the current test variant
…isibleForTesting and exempt its usage in flutter_test
bf1725b to
e11be71
Compare
flutter/flutter@02a6c91...d02292d 2024-05-21 [email protected] Make FileSystem dependency explicit througout (more). (flutter/flutter#148095) 2024-05-20 [email protected] Remove add-to-app bitcode warning (flutter/flutter#148587) 2024-05-20 [email protected] SelectionArea's selection should not be cleared on loss of window focus (flutter/flutter#148067) 2024-05-20 [email protected] [wiki migration] Engine team pages (flutter/flutter#148696) 2024-05-20 [email protected] Manual roll camera dependency (flutter/flutter#148426) 2024-05-20 [email protected] [wiki migration] Framework team pages (flutter/flutter#148721) 2024-05-20 [email protected] Roll Flutter Engine from a8fb9daae8d0 to c2ef01f6f1ab (3 revisions) (flutter/flutter#148722) 2024-05-20 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.5 to 3.25.6 (flutter/flutter#148715) 2024-05-20 49699333+dependabot[bot]@users.noreply.github.com Bump codecov/codecov-action from 4.4.0 to 4.4.1 (flutter/flutter#148714) 2024-05-20 [email protected] Fixes incorrect read/write permissions on Flutter.framework and FlutterMacOS.framework (flutter/flutter#148580) 2024-05-20 [email protected] Roll Flutter Engine from c6fecf65fbf3 to a8fb9daae8d0 (3 revisions) (flutter/flutter#148700) 2024-05-20 [email protected] Remove the no-shuffle tag on the flutter_tools create_test suite (flutter/flutter#148688) 2024-05-20 [email protected] log incoming vm service messages in `FlutterVMService::runInView` (flutter/flutter#148596) 2024-05-20 [email protected] Add tests for shared_app_data.#.dart API examples. (flutter/flutter#147830) 2024-05-20 [email protected] Add tests for logical_key_set.0.dart API example. (flutter/flutter#147735) 2024-05-20 [email protected] [wiki migration] Ecosystem team pages (flutter/flutter#148589) 2024-05-20 [email protected] Fix painting API examples tests directories structure. (flutter/flutter#148177) 2024-05-20 [email protected] fixes `CupertinoModalPopupRoute` (flutter/flutter#147823) 2024-05-20 [email protected] Implement new `AnimationStatus` getters (flutter/flutter#148570) 2024-05-20 [email protected] Reland "`if` chains � `switch` expressions" (flutter/flutter#148634) 2024-05-20 [email protected] Factor out `RawView`, make `View` listen to engine generated view focus events (flutter/flutter#143259) 2024-05-20 [email protected] Remove all tests from a02s. Replace with mokey in bringup (flutter/flutter#148563) 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],[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
…-coder-xu/flutter into fix/slider_text_null_error * 'fix/slider_text_null_error' of https://github.com/hello-coder-xu/flutter: (65 commits) Change implementation method fix slider text null error Make FileSystem dependency explicit througout (more). (flutter#148095) Remove add-to-app bitcode warning (flutter#148587) SelectionArea's selection should not be cleared on loss of window focus (flutter#148067) [wiki migration] Engine team pages (flutter#148696) Manual roll camera dependency (flutter#148426) [wiki migration] Framework team pages (flutter#148721) Roll Flutter Engine from a8fb9daae8d0 to c2ef01f6f1ab (3 revisions) (flutter#148722) Bump github/codeql-action from 3.25.5 to 3.25.6 (flutter#148715) Bump codecov/codecov-action from 4.4.0 to 4.4.1 (flutter#148714) Fixes incorrect read/write permissions on Flutter.framework and FlutterMacOS.framework (flutter#148580) Roll Flutter Engine from c6fecf65fbf3 to a8fb9daae8d0 (3 revisions) (flutter#148700) Remove the no-shuffle tag on the flutter_tools create_test suite (flutter#148688) log incoming vm service messages in `FlutterVMService::runInView` (flutter#148596) Add tests for shared_app_data.#.dart API examples. (flutter#147830) Add tests for logical_key_set.0.dart API example. (flutter#147735) [wiki migration] Ecosystem team pages (flutter#148589) Fix painting API examples tests directories structure. (flutter#148177) fixes `CupertinoModalPopupRoute` (flutter#147823) ...
flutter/flutter@02a6c91...d02292d 2024-05-21 [email protected] Make FileSystem dependency explicit througout (more). (flutter/flutter#148095) 2024-05-20 [email protected] Remove add-to-app bitcode warning (flutter/flutter#148587) 2024-05-20 [email protected] SelectionArea's selection should not be cleared on loss of window focus (flutter/flutter#148067) 2024-05-20 [email protected] [wiki migration] Engine team pages (flutter/flutter#148696) 2024-05-20 [email protected] Manual roll camera dependency (flutter/flutter#148426) 2024-05-20 [email protected] [wiki migration] Framework team pages (flutter/flutter#148721) 2024-05-20 [email protected] Roll Flutter Engine from a8fb9daae8d0 to c2ef01f6f1ab (3 revisions) (flutter/flutter#148722) 2024-05-20 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.5 to 3.25.6 (flutter/flutter#148715) 2024-05-20 49699333+dependabot[bot]@users.noreply.github.com Bump codecov/codecov-action from 4.4.0 to 4.4.1 (flutter/flutter#148714) 2024-05-20 [email protected] Fixes incorrect read/write permissions on Flutter.framework and FlutterMacOS.framework (flutter/flutter#148580) 2024-05-20 [email protected] Roll Flutter Engine from c6fecf65fbf3 to a8fb9daae8d0 (3 revisions) (flutter/flutter#148700) 2024-05-20 [email protected] Remove the no-shuffle tag on the flutter_tools create_test suite (flutter/flutter#148688) 2024-05-20 [email protected] log incoming vm service messages in `FlutterVMService::runInView` (flutter/flutter#148596) 2024-05-20 [email protected] Add tests for shared_app_data.#.dart API examples. (flutter/flutter#147830) 2024-05-20 [email protected] Add tests for logical_key_set.0.dart API example. (flutter/flutter#147735) 2024-05-20 [email protected] [wiki migration] Ecosystem team pages (flutter/flutter#148589) 2024-05-20 [email protected] Fix painting API examples tests directories structure. (flutter/flutter#148177) 2024-05-20 [email protected] fixes `CupertinoModalPopupRoute` (flutter/flutter#147823) 2024-05-20 [email protected] Implement new `AnimationStatus` getters (flutter/flutter#148570) 2024-05-20 [email protected] Reland "`if` chains � `switch` expressions" (flutter/flutter#148634) 2024-05-20 [email protected] Factor out `RawView`, make `View` listen to engine generated view focus events (flutter/flutter#143259) 2024-05-20 [email protected] Remove all tests from a02s. Replace with mokey in bringup (flutter/flutter#148563) 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],[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
…us (flutter#148067) This change fixes an issue where SelectionArea would clear its selection when the application window lost focus by first checking if the application is running. This is needed because `FocusManager` is aware of the application lifecycle as of flutter#142930 , and triggers a focus lost if the application is not active. Also fixes an issue where the `FocusManager` was not being reset on tests at the right time, causing it always to build with `TargetPlatform.android` as its context.

This change fixes an issue where SelectionArea would clear its selection when the application window lost focus by first checking if the application is running. This is needed because
FocusManageris aware of the application lifecycle as of #142930 , and triggers a focus lost if the application is not active.Also fixes an issue where the
FocusManagerwas not being reset on tests at the right time, causing it always to build withTargetPlatform.androidas its context.Pre-launch Checklist
///).