Skip to content

[Inspector V2] Handle selection of an implementation widget in the app - #8494

Merged
elliette merged 5 commits into
flutter:masterfrom
elliette:issue-8465
Oct 31, 2024
Merged

elliette merged 5 commits into
flutter:masterfrom
elliette:issue-8465

Conversation

@elliette

Copy link
Copy Markdown
Member

Fixes #8465

This PR fixes two issues around widget selection:

  1. A user has implementation widgets visible in their tree, but they select an implementation widget in their app that is currently hidden behind a collapsed group
    Before: The tree would not scroll, and no node would be selected
    Now: The collapsed group is expanded, and we scroll to and select the implementation widget

  2. A user has hidden all implementation widgets in their tree, but they select an implementation widget in their app
    Before: The selection overlay would disappear on their app, and DevTools would scroll to the root of their tree
    Now: The selection overlay stays on their app, DevTools does not scroll but shows an error notification that they need to toggle "Show Implementation Widgets" to inspect the selected widget
    Note: An alternative would be to add logic to Flutter's Widget Inspector so that when DevTools has implementation widgets hidden, we don't let the user select them in their app. I'm not sure if that would be more or less confusing.

@elliette
elliette requested a review from a team as a code owner October 30, 2024 18:05
@elliette
elliette requested review from kenzieschmoll and removed request for a team October 30, 2024 18:05
@elliette elliette changed the title Handle selection of an implementation widget in the app [Inspector V2] Handle selection of an implementation widget in the app Oct 30, 2024
if (implementationWidgetsHidden.value && newSelection != null) {
final isInTree =
valueToInspectorTreeNode.containsKey(newSelection.valueRef);
final hasParent = newSelection.parent != null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just for my understanding, how does the presence of a parent tell us whether whether the user selected an implementation widget?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The Widget Inspector's response includes the children for each node, but not the parent. When DevTools receives the response, it walks down the tree and sets the parent for a node. This is basically a way of check that not only is the node not in the current tree, but it was never part of the response we were given. Since we know the implementation widgets are hidden, we can assume that the selected node is an implementation widget.

Comment thread packages/devtools_app/lib/src/screens/inspector_v2/inspector_controller.dart Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

After a selecting a widget in the app, the Inspector tree does not always scroll to the widget

2 participants