Skip to content

Conversation

@gspencergoog
Copy link
Contributor

@gspencergoog gspencergoog commented Feb 10, 2024

Description

This factors out a separate RawView that doesn't add a MediaQuery or a FocusScope. This PR also adds a new method WidgetsBindingObserver.didChangeViewFocus which allows the observer to know when the FlutterView that has focus has changed.

It also makes the View widget a stateful widget that contains a FocusScope and FocusTraversalGroup so that it can respond to changes in the focus of the view.

I've also added a new function to FocusScopeNode that will allow the scope node itself to be focused, without looking for descendants that could take the focus. This lets the focus be "parked" at the FocusManager.instance.rootScope so that nothing else appears to have focus.

Tests

  • Added tests for the new functionality.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: focus Focus traversal, gaining or losing focus labels Feb 10, 2024
@ditman
Copy link
Member

ditman commented Mar 11, 2024

I've deployed the latest version of this PR with a small multi-view test web app I have, and it works beautifully!

@goderbauer
Copy link
Member

Looks like this is failing many checks...

@gspencergoog
Copy link
Contributor Author

gspencergoog commented Mar 25, 2024

Wait... Something is very off about this PR. There's a lot of code in there that I didn't write for this PR. Let me try re-merging and push again.

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

Will look again later!

@ditman ditman requested a review from tugorez March 25, 2024 22:50
@ditman
Copy link
Member

ditman commented Mar 25, 2024

(Also calling @tugorez since he worked on the engine side of things)

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

This pretty much looks good to me. I would like to see RawView get separated out of this and it looks like this is still failing tests.

@github-actions github-actions bot added the a: tests "flutter test", flutter_test, or one of our tests label Mar 26, 2024
@gspencergoog gspencergoog changed the title Make View listen to engine generated view focus events Factor out RawView, make View listen to engine generated view focus events Mar 26, 2024
@tugorez
Copy link
Contributor

tugorez commented Mar 26, 2024

I've deployed the latest version of this PR with a small multi-view test web app I have, and it works beautifully!

@ditman do you mind redeploying the app with the latest changes?

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

@gspencergoog gspencergoog added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 26, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Mar 26, 2024

auto label is removed for flutter/flutter/143259, due to - The status or check suite Mac customer_testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 26, 2024
@ditman
Copy link
Member

ditman commented Mar 27, 2024

I've deployed the latest version of this PR with a small multi-view test web app I have, and it works beautifully!

@ditman do you mind redeploying the app with the latest changes?

Redeployed. Apologies for the delay @tugorez!

@ditman
Copy link
Member

ditman commented Mar 27, 2024

I took a quick look at the failing web tests, and most of them (all?) seem to be related to the changes in the widget tree, and tests having "golden" expectations of full debugWidgetTrees or whatever we call this:

Expected: normalized value matches RenderPadding#00000 relayoutBoundary=up1
           │ creator: Padding ← Container ← Align ← MediaQuery ←
           │   _MediaQueryFromView ← _PipelineOwnerScope ← _ViewScope ←
           │   _RawView-[_DeprecatedRawViewKey TestFlutterView#00000] ← View ←
           │   [root]
           │ parentData: offset=Offset(0.0, 0.0) (can use size)
           │ constraints: BoxConstraints(0.0<=w<=800.0, 0.0<=h<=600.0)
           │ size: Size(63.0, 88.0)
           │ padding: EdgeInsets.all(5.0)
           │
           └─child: RenderConstrainedBox#00000 relayoutBoundary=up2
             │ creator: ConstrainedBox ← Padding ← Container ← Align ←
             │   MediaQuery ← _MediaQueryFromView ← _PipelineOwnerScope ←
             │   _ViewScope ← _RawView-[_DeprecatedRawViewKey
             │   TestFlutterView#00000] ← View ← [root]
             │ parentData: offset=Offset(5.0, 5.0) (can use size)
             │ constraints: BoxConstraints(0.0<=w<=790.0, 0.0<=h<=590.0)
             │ size: Size(53.0, 78.0)
             │ additionalConstraints: BoxConstraints(w=53.0, h=78.0)
             │
             └─child: RenderDecoratedBox#00000
               │ creator: DecoratedBox ← ConstrainedBox ← Padding ← Container ←
               │   Align ← MediaQuery ← _MediaQueryFromView ← _PipelineOwnerScope
               │   ← _ViewScope ← _RawView-[_DeprecatedRawViewKey
               │   TestFlutterView#00000] ← View ← [root]
               │ parentData: <none> (can use size)
               │ constraints: BoxConstraints(w=53.0, h=78.0)
               │ size: Size(53.0, 78.0)
               │ decoration: BoxDecoration:
   .... (and much more)

I can help updating the "goldens" if needed, do ping me if we want to fix like that, or there's another way I don't see :)

@tugorez
Copy link
Contributor

tugorez commented Mar 27, 2024

@gspencergoog one thing I notice while traversing multiple counters in https://dit-multiview-tests.web.app/ is that it requires two tabs to go from the button in a given view A to the button in the adjacent view B (either before or after A).

auto-submit bot pushed a commit to flutter/engine that referenced this pull request May 2, 2024
@tugorez
Copy link
Contributor

tugorez commented May 8, 2024

@gspencergoog I think this PR is ready to be landed.

@github-actions github-actions bot added the f: material design flutter/packages/flutter/material repository. label May 8, 2024
@gspencergoog gspencergoog added the autosubmit Merge PR when tree becomes green via auto submit App label May 17, 2024
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 17, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented May 17, 2024

auto label is removed for flutter/flutter/143259, due to - The status or check suite Linux analyze has failed. Please fix the issues identified (or deflake) before re-applying this label.

@gspencergoog gspencergoog added the autosubmit Merge PR when tree becomes green via auto submit App label May 17, 2024
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 17, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented May 17, 2024

auto label is removed for flutter/flutter/143259, due to - The status or check suite Linux customer_testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@gspencergoog gspencergoog added the autosubmit Merge PR when tree becomes green via auto submit App label May 20, 2024
@auto-submit auto-submit bot merged commit 333c076 into flutter:master May 20, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2024
@polina-c polina-c mentioned this pull request May 21, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request May 21, 2024
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
TecHaxter pushed a commit to TecHaxter/flutter_packages that referenced this pull request May 22, 2024
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
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: tests "flutter test", flutter_test, or one of our tests autosubmit Merge PR when tree becomes green via auto submit App f: focus Focus traversal, gaining or losing focus f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants