Skip to content
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

[Inspector V2] Prevent inspector tree scroll from bouncing #8367

Merged
merged 4 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -990,9 +990,14 @@ class _InspectorTreeState extends State<InspectorTree>
safeViewportHeight,
);

// Decide to scroll based on whether the middle of the center-left half of
// the row is visible. See https://github.com/flutter/devtools/pull/8367.
final centerLeftHalf = Offset(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth leaving some documentation here explaining why we do this and referencing the original issue (or this PR)? ASCII art could work too ;-)

Copy link
Member

Choose a reason for hiding this comment

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

Plus one to a comment and issue link 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

(rect.centerLeft.dx + rect.center.dx) / 2,
rect.center.dy,
);
final isRectInViewPort =
viewPortInScrollControllerSpace.contains(rect.topLeft) &&
viewPortInScrollControllerSpace.contains(rect.bottomRight);
viewPortInScrollControllerSpace.contains(centerLeftHalf);
if (isRectInViewPort) {
// The rect is already in view, don't scroll
return;
Expand Down