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

Fix ReorderableListView's use of child keys (#41334) #41338

Merged
merged 6 commits into from Sep 27, 2019

Conversation

krisgiesing
Copy link
Contributor

@krisgiesing krisgiesing commented Sep 26, 2019

Description

ReorderableListView was constructing a GlobalObjectKey using the child key as the value. This only had the intended behavior if the child key was identical across build method invocations.

The new strategy is to scope the child key's value to the State object's identity, allowing child keys to have value compare semantics while disambiguating among different list view instances.

Related Issues

#41334 - fixed

Tests

Updated test/material/reorderable_list_test.dart to add 'Preserves children states across reorder when keys are not identical'.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

ReorderableListView was constructing a GlobalObjectKey using
the child key as the value. This only had the intended behavior
if the child key was identical across build method invocations.

The new strategy is to scope the child key's value to the
State object's identity, allowing child keys to have value
compare semantics while disambiguating among different list view
instances.
@fluttergithubbot fluttergithubbot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Sep 26, 2019
@fluttergithubbot
Copy link
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. While there are exceptions to this rule, if this patch modifies code it is probably not an exception.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@krisgiesing
Copy link
Contributor Author

@Hixie ready for review, I think.

@Hixie
Copy link
Contributor

Hixie commented Sep 26, 2019

This is great.

@Hixie
Copy link
Contributor

Hixie commented Sep 26, 2019

Some analyzer warnings but otherwise LGTM.

@krisgiesing krisgiesing merged commit 2b138fd into flutter:master Sep 27, 2019
Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Sep 30, 2019
…41338)

ReorderableListView was constructing a GlobalObjectKey using
the child key as the value. This only had the intended behavior
if the child key was identical across build method invocations.

The new strategy is to scope the child key's value to the
State object's identity, allowing child keys to have value
compare semantics while disambiguating among different list view
instances.
@slightfoot
Copy link
Member

slightfoot commented Oct 3, 2019

@Hixie Looks like this change has broken something. This is gallery ReorderableList demo: https://github.com/flutter/flutter/blob/master/examples/flutter_gallery/lib/demo/material/reorderable_list_demo.dart

Flutter 1.10.7 • channel dev • https://github.com/flutter/flutter.git
Framework • revision e70236e36c (27 hours ago) • 2019-10-02 09:32:30 -0700
Engine • revision 9e6314d348
Tools • Dart 2.6.0 (build 2.6.0-dev.4.0 1103600280)

screenshot-2019-10-03_20 05 22 156

I am experiencing the same issue in my current app I am building.

@Hixie
Copy link
Contributor

Hixie commented Oct 3, 2019

cc @krisgiesing can you revert while the issue is being investigated?

I wonder what's going on...

@krisgiesing
Copy link
Contributor Author

The issue preventing this from landing has been narrowed down to a test that doesn't use ReorderableListView, captured in #43780.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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.

None yet

6 participants