这是indexloc提供的服务,不要输入任何密码
Skip to content

Add draggable parameter to ReorderableDragStartListener #81396

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

ValentinVignal
Copy link
Contributor

@ValentinVignal ValentinVignal commented Apr 28, 2021

This PR is adding a parameter draggable to the widget ReorderableDragStartListener. This allows the user to dynamically activate/deactivate the drag/drop behaviour for some items in the ReorderableListView without changing the tree structure ; and therefore losing the state of the the stateful widgets inside the items of the list.

List which issues are fixed by this PR. You must list at least one issue.
#81395

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Apr 28, 2021
@google-cla google-cla bot added the cla: yes label Apr 28, 2021
@ValentinVignal
Copy link
Contributor Author

Please let me know if I missed something

@goderbauer goderbauer requested a review from darrenaustin April 28, 2021 21:43
Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

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

Thanks so much for the contribution! I totally missed this use case when I was developing the drag listeners.

I have a few comments and suggestions below that will need to be addressed before we can merge this, but otherwise this looks good. Thanks for including tests.

Let me know if there is anything that isn't clear, or if you aren't interested in taking this further. Thanks again.

…arameter

# Conflicts:
#	packages/flutter/test/widgets/reorderable_list_test.dart
@ValentinVignal ValentinVignal marked this pull request as draft May 1, 2021 14:43
@ValentinVignal ValentinVignal marked this pull request as ready for review May 1, 2021 15:39
@ValentinVignal
Copy link
Contributor Author

ValentinVignal commented May 1, 2021

@darrenaustin I applied the changes you requested, let me know if I should do something more.

Also, I am a bit confused:

  • For the ReorderableDragStartListener tests, I have to drag the item 0 to Offset(0, 150) to reorder it at the second position.
  • For the ReorderableDelayedDragStartListener tests, I have to drag the item 0 to Offset(0, 50) to reorder it at the second position.

I tried to investigate why I was having these different behaviours but I didn't found anything.
I wanted to use golden images to have more information, but for some reasons, adding

await expectLater(find.byType(ReorderableListView), matchesGoldenFile('golden.png'));

doesn't generate any image.

Do you have an explanation or could you highlight me on how to debug/investigate the test runs ?

Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

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

@darrenaustin I applied the changes you requested, let me know if I should do something more.

Looks good thanks. I have a small issue I missed the first time (see new comment). Also it looks like there is a merge conflict with what is on the master branch, so that will need to be resolved before we can land this.

Also, I am a bit confused:

  • For the ReorderableDragStartListener tests, I have to drag the item 0 to Offset(0, 150) to reorder it at the second position.
  • For the ReorderableDelayedDragStartListener tests, I have to drag the item 0 to Offset(0, 50) to reorder it at the second position.

That is odd. I spent a bunch time looking into this and it appears to be a bug with the drag calculations on the very first drag update event. It will be off by the size of the gap, but only for the first update. The current tests that are based off of moving the item by 150 are incorrect, and should only need to move by 50. The reason it works fine for the delayed listener is that under the covers it generates two update events on the start of the drag, and the second one uses the correct calculation. I am looking into fixing this, but go ahead and use the values you have in your tests now and if this lands before I can fix it will update them with my fix. Thanks for pointing this out!

I tried to investigate why I was having these different behaviours but I didn't found anything.
I wanted to use golden images to have more information, but for some reasons, adding

await expectLater(find.byType(ReorderableListView), matchesGoldenFile('golden.png'));

This may not give you what you want here, text in golden images are just blocks of color to avoid font changes effecting golden tests. In addition you wouldn't be able to see the dragged item as it is in an overlay, so you would have to include the top level overlay to get the full image. All that said, when you run this with a new golden image it should have given you a directory where the generated images were.

…tart-listener/draggable-parameter

# Conflicts:
#	packages/flutter/test/widgets/reorderable_list_test.dart
@ValentinVignal
Copy link
Contributor Author

ValentinVignal commented May 5, 2021

Thank you for all those precisions and feedbacks @darrenaustin!

I applied your requests changes. I hope everything is fine now :)


Also it looks like the windows tests are failing ("download dependencies"). Is it because of my changes?

Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

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

flutter-lgtm

Thanks for working through all the issues here.

@darrenaustin
Copy link
Contributor

Also it looks like the windows tests are failing ("download dependencies"). Is it because of my changes?

Looks like it was an infra problem on the test machines. I have restarted the tests and hopefully they will go through this time.

@ValentinVignal
Copy link
Contributor Author

Looks like it was an infra problem on the test machines. I have restarted the tests and hopefully they will go through this time.

Ok, good to know, let me know if I can do something else.

@darrenaustin
Copy link
Contributor

Looks like it was an infra problem on the test machines. I have restarted the tests and hopefully they will go through this time.

Ok, good to know, let me know if I can do something else.

Hi @ValentinVignal, there is still a windows test that is not passing, but I think it is a test that has been updated or turned off on the master branch. Can you pull in the latest from master and rebase your stuff on top of it? I think that will finally allow us to land this. Thx.

@ValentinVignal
Copy link
Contributor Author

Hi @ValentinVignal, there is still a windows test that is not passing, but I think it is a test that has been updated or turned off on the master branch. Can you pull in the latest from master and rebase your stuff on top of it? I think that will finally allow us to land this. Thx.

Hello @darrenaustin it looks like the windows test is not failing anymore 👍 . Thank you for monitoring this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants