-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Draggable feedback positioning #149040
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
Draggable feedback positioning #149040
Conversation
dkwingsmt
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!
justinmc
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 👍. Thanks for following up after the revert.
I wish we had an automated way to catch this lack of .up calls. I was just asking @polina-c about this.
|
|
||
| // Finish gesture to release resources. | ||
| await gesture.up(); | ||
| await tester.pumpAndSettle(); |
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.
Nit: Should this be pump? Just noticing that it's usually pump elsewhere. Same for the two new tests below.
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.
Good point, works just as well with pump! I think I just copied the three lines from the test right above the ones I added without thinking too much about it. Fixed!
When I worked on mouse we immediately add gesture.up to tear down after the However a bigger problem for me is that, the error seems to be triggered by the case where the dragging widget is unmounted during a drag, which is a totally normal case. Will this case trigger error in prod? If so we should fix this case instead of avoiding them in the tests. |
|
Ok, I've tested that this will trigger error if the root widget (which supposedly provides the overlay) is take away during the drag. Reproduction:
void updateDrag(Offset globalPosition) {
final RenderBox box = overlayState.context.findRenderObject()! as RenderBox;
final Offset overlaySpaceOffset = box.globalToLocal(globalPosition);
print(overlaySpaceOffset - dragStartPoint);
import 'package:flutter/material.dart';
class Main extends StatefulWidget {
@override
_MainState createState() => _MainState();
}
class _MainState extends State<Main> {
bool _show = true;
@override
Widget build(BuildContext context) {
return !_show ? Container() : MaterialApp(
home: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
DragTarget<int>(
builder: (BuildContext context, List<int?> data, List<dynamic> rejects) {
return const Text('Target');
},
onAcceptWithDetails: (DragTargetDetails<int> _) {
},
),
Container(width: 400.0),
Draggable<int>(
data: 1,
feedback: Text('H'),
onDragStarted: () {
Future<void>.delayed(Duration(seconds: 2)).then((_) {
setState(() {
_show = false;
});
});
},
childWhenDragging: SizedBox(),
axis: Axis.horizontal,
child: Text('H'),
),
],
),
);
}
}
void main() {
runApp(Main());
}
Throws error: We should probably fix this error instead of patching the tests. |
dkwingsmt
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.
See comment
|
Thanks for finding this, that's very insightful. As I mentioned on the other PR it didn't quite sit right with me that the test failures were triggered by the changes. I will take a look at this again! |
|
@dkwingsmt I added a new test that verifies the behaviour you found when unmounting, and added a mounted check to the context access in Thanks again for your help! |
dkwingsmt
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, thanks for working on this!
|
I would prefer removing the Awesome test for the graceful unmounting, BTW! |
justinmc
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, but see the analyzer failure.
01ab09b to
5d331e1
Compare
Removed them all! Thanks :) |
@justinmc Ready, it's all green 🌿 |
|
@dkwingsmt @justinmc Just wanted to touch base again, is there anything you still need from me? |
|
Nope. Here we go! Thanks for the work! |
Manual roll requested by [email protected] flutter/flutter@15f95ce...651a17d 2024-06-28 [email protected] Roll Flutter Engine from a78f5ce743ce to 2f7e9ab27493 (11 revisions) (flutter/flutter#151002) 2024-06-28 [email protected] Draggable feedback positioning (flutter/flutter#149040) 2024-06-28 [email protected] Add support for type-safe plugin apply (flutter/flutter#150958) 2024-06-28 [email protected] Use caret syntax with flutter create command (flutter/flutter#150920) 2024-06-28 [email protected] Roll Packages from 03f5f6d to 412ec46 (12 revisions) (flutter/flutter#150985) 2024-06-28 [email protected] [flutter_tools] Include more details in structured errors sent to a DAP client (flutter/flutter#150698) 2024-06-28 [email protected] Roll Flutter Engine from 94591ffb20df to a78f5ce743ce (1 revision) (flutter/flutter#150972) 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
Reopened after revert in flutter#147658 Another test was added in the meantime to `draggable_test.dart` that didn't call `gesture.up()`. I added this call to the test and now all tests pass. --- # Original Description (flutter#145647): We changed the coordinates used to position the `Draggable` feedback by transforming them into the `Overlay`s coordinate space. This has no influence on any untransformed `Overlay`, most Flutter apps should be not affected. This PR fixes the positioning of the feedback in transformed context (see flutter#145639 for before video): https://github.com/flutter/flutter/assets/42270125/df34e198-0667-453d-a27a-a79b2e2825a1 - fixes flutter#145639 ## 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. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat [Data Driven Fixes]: https://github.com/flutter/flutter/wiki/Data-driven-Fixes --------- Co-authored-by: Jesper Bellenbaum <[email protected]>
Reopened after revert in #147658
Another test was added in the meantime to
draggable_test.dartthat didn't callgesture.up(). I added this call to the test and now all tests pass.Original Description (#145647):
We changed the coordinates used to position the
Draggablefeedback by transforming them into theOverlays coordinate space. This has no influence on any untransformedOverlay, most Flutter apps should be not affected.This PR fixes the positioning of the feedback in transformed context (see #145639 for before video):
Screenshot.2024-03-23.at.20.30.06.mp4
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.