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

ExpansionPanel isExpanded callback parameter (Ticket 74114) #128082

Merged
merged 8 commits into from Jun 9, 2023

Conversation

dleyba042
Copy link
Contributor

@dleyba042 dleyba042 commented Jun 1, 2023

Fixes #74114

This PR addresses the issue detailed here: #74114 . The boolean isExpanded returned by the expansion panel callback now reflects the state of the panel that the user is seeing. If it's expanded on screen then the callback returns true. When you close the panel the callback returns false. When another panel is open and you open a different one, the callback executes twice. It returns isExpanded == false for the panel you are closing and true for the panel that is being opened.
I had to change the code in a couple existing tests because some tests are using the old behavior of the callback. This PR addresses feedback listed in closed PR -> #127876 . The reasone the original PR is closed is that I was having some struggles with git. A couple of the commits in this PR are just reverts of commits I meant not to happen.
Pre-launch Checklist

[ X] I read the [Contributor Guide](https://github.com/flutter/flutter/wiki/Tree-hygiene#overview) and followed the process outlined there for submitting PRs.
[ X] I read the [Tree Hygiene](https://github.com/flutter/flutter/wiki/Tree-hygiene) wiki page, which explains my responsibilities.
[ X] I read and followed the [Flutter Style Guide](https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo), including [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).
[ X] I signed the [CLA](https://cla.developers.google.com/).
[ X] I listed at least one issue that this PR fixes in the description above.
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](https://github.com/flutter/flutter/wiki/Tree-hygiene#tests).
[ X] 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 f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. team Infra upgrades, team productivity, code health, technical debt. See also team: labels. labels Jun 1, 2023
@Piinks Piinks self-requested a review June 1, 2023 22:31
@HansMuller HansMuller changed the title Ticket 74114 ExpansionPanel isExpanded callback parameter (Ticket 74114) Jun 1, 2023
@github-actions github-actions bot removed the f: material design flutter/packages/flutter/material repository. label Jun 2, 2023
@flutter-dashboard flutter-dashboard bot added the f: material design flutter/packages/flutter/material repository. label Jun 2, 2023
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

packages/flutter/lib/src/material/expansion_panel.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/expansion_panel.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/expansion_panel.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/expansion_panel.dart Outdated Show resolved Hide resolved
_currentOpenPanel = isExpanded ? null : pressedChild;
});
}
else
{
widget.expansionCallback?.call(index, !isExpanded);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since it looks like this is called either way (in the if or else block), can the else block be removed and it just be called unconditionally after the if statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that was an oversight. I refactored and all tests are still passing.

@@ -144,7 +144,7 @@ void main() {
expect(find.byType(ExpandIcon), findsOneWidget);
await tester.tap(find.byType(ExpandIcon));
expect(capturedIndex, 0);
expect(capturedIsExpanded, isFalse);
expect(capturedIsExpanded, isTrue);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this issue has existed for a while, developers may be broken by this. I am going to run some extra tests internally to see if it breaks anyone.

Copy link
Contributor Author

@dleyba042 dleyba042 Jun 3, 2023

Choose a reason for hiding this comment

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

Ok, sounds good, thanks again for the help.

@github-actions github-actions bot removed the f: material design flutter/packages/flutter/material repository. label Jun 3, 2023
@dleyba042
Copy link
Contributor Author

@Piinks I addressed your feedback, thanks again!

Copy link
Contributor

@Piinks Piinks 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

Still checking a few more test avenues to avoid this potentially getting reverted later, I'll add the autosubmit label once it is ready to go!

@dleyba042
Copy link
Contributor Author

@Piinks sounds good, thanks for checking.

@Piinks
Copy link
Contributor

Piinks commented Jun 6, 2023

All set, thanks for your patience!

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 6, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 6, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Jun 6, 2023

auto label is removed for flutter/flutter, pr: 128082, due to This PR has not met approval requirements for merging. You are not a member of flutter-hackers and need 1 more review(s) in order to merge this PR.

  • Merge guidelines: You need at least one approved review if you are already part of flutter-hackers or two member reviews if you are not a flutter-hacker before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@Piinks
Copy link
Contributor

Piinks commented Jun 6, 2023

Ah we need one more approval. On it!

@goderbauer goderbauer added the f: material design flutter/packages/flutter/material repository. label Jun 6, 2023
@dleyba042
Copy link
Contributor Author

I left a link to the PR in the Discord channel to see if anyone could review.

@Piinks
Copy link
Contributor

Piinks commented Jun 8, 2023

Hmm.. likewise. Let me see if I can motivate. :)

@dleyba042
Copy link
Contributor Author

sounds good. :) just figured I would put a request out there.

@Piinks
Copy link
Contributor

Piinks commented Jun 8, 2023

Oh of course! You are more than welcome too, I just feel bad no one came around yet. We'll see about getting this checked out.

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM, just some formatting nits. Thanks for the PR!

packages/flutter/lib/src/material/expansion_panel.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/expansion_panel.dart Outdated Show resolved Hide resolved
packages/flutter/test/material/expansion_panel_test.dart Outdated Show resolved Hide resolved
packages/flutter/test/material/expansion_panel_test.dart Outdated Show resolved Hide resolved
packages/flutter/test/material/expansion_panel_test.dart Outdated Show resolved Hide resolved
packages/flutter/test/material/expansion_panel_test.dart Outdated Show resolved Hide resolved
@dleyba042
Copy link
Contributor Author

@justinmc thanks for the review. I made the changes you asked for.

@auto-submit auto-submit bot merged commit 5047690 into flutter:master Jun 9, 2023
139 checks passed
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jun 11, 2023
flutter/flutter@da127f1...3df163f

2023-06-11 engine-flutter-autoroll@skia.org Roll Flutter Engine from 73a7af805472 to 1cca9cc6dbd1 (1 revision) (flutter/flutter#128658)
2023-06-11 engine-flutter-autoroll@skia.org Roll Flutter Engine from 7c6770083e5c to 73a7af805472 (2 revisions) (flutter/flutter#128654)
2023-06-11 engine-flutter-autoroll@skia.org Roll Flutter Engine from 6d615bbcfccf to 7c6770083e5c (2 revisions) (flutter/flutter#128653)
2023-06-11 engine-flutter-autoroll@skia.org Roll Flutter Engine from b19b93de5b0a to 6d615bbcfccf (1 revision) (flutter/flutter#128650)
2023-06-11 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3d76ba6d6d5f to b19b93de5b0a (2 revisions) (flutter/flutter#128649)
2023-06-11 engine-flutter-autoroll@skia.org Roll Flutter Engine from 962d78e0ae9c to 3d76ba6d6d5f (1 revision) (flutter/flutter#128645)
2023-06-10 31859944+LongCatIsLooong@users.noreply.github.com migrate `Tooltip` to use  `OverlayPortal` (flutter/flutter#127728)
2023-06-10 engine-flutter-autoroll@skia.org Roll Flutter Engine from b037db26037f to 962d78e0ae9c (10 revisions) (flutter/flutter#128643)
2023-06-10 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 3.5.2 to 3.5.3 (flutter/flutter#128625)
2023-06-10 engine-flutter-autoroll@skia.org Roll Flutter Engine from 3e90345cdca7 to b037db26037f (1 revision) (flutter/flutter#128627)
2023-06-10 devZhulanov.A.A@gmail.com Remove unnecessary parentheses (flutter/flutter#128620)
2023-06-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 488876ed26c6 to 3e90345cdca7 (3 revisions) (flutter/flutter#128617)
2023-06-09 andrewrkolos@gmail.com rename generated asset manifest file back to `AssetManifest.bin` (from `AssetManifest.smcbin`) (flutter/flutter#128529)
2023-06-09 jhy03261997@gmail.com Add Selected semantics to IconButton (flutter/flutter#128547)
2023-06-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 071e1fb21c7a to 488876ed26c6 (5 revisions) (flutter/flutter#128612)
2023-06-09 47866232+chunhtai@users.noreply.github.com Clarifies semantics long press and semantics on tap documentation (flutter/flutter#128599)
2023-06-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from bc6e047570f6 to 071e1fb21c7a (1 revision) (flutter/flutter#128602)
2023-06-09 hans.muller@gmail.com Revert "Update `chip.dart` to use set of `MaterialState`" (flutter/flutter#128607)
2023-06-09 devZhulanov.A.A@gmail.com Add tooltips for `SegmentedButton` (flutter/flutter#128501)
2023-06-09 jason-simmons@users.noreply.github.com Ignore app.stop events received before the app.detach response in attach integration tests (flutter/flutter#128593)
2023-06-09 dleyba042@gmail.com ExpansionPanel isExpanded callback parameter (Ticket 74114) (flutter/flutter#128082)
2023-06-09 engine-flutter-autoroll@skia.org Roll Flutter Engine from 93afba901b3b to bc6e047570f6 (3 revisions) (flutter/flutter#128594)
2023-06-09 hans.muller@gmail.com Updated flutter_localizations tests for Material3; (flutter/flutter#128521)
2023-06-09 jhy03261997@gmail.com Paint SelectableFragments before text (flutter/flutter#128375)
2023-06-09 engine-flutter-autoroll@skia.org Roll Packages from e13b8c4 to afe2f05 (7 revisions) (flutter/flutter#128582)

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 rmistry@google.com,stuartmorgan@google.com 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@your-diary
Copy link

After upgrading to Flutter 3.13 today, I encountered an bug due to this PR.
Previously working code doesn't work in Flutter 3.13 at all because this PR flips the flag passed to expansionCallback().

I had very hard time debugging the issue.
This PR introduces a breaking change but where does this referred to in the changelog?

@justinmc
Copy link
Contributor

@your-diary Only changes that break tests are officially considered to be breaking changes, see this section of the wiki.

That said, we don't want to change any behavior for users of ExpansionPanel. Can you file a new issue and link it here?

@dleyba042 Any idea what we can do here?

auto-submit bot pushed a commit that referenced this pull request Aug 21, 2023
…callback (#132837)

fixes [ExpansionPanelList can't expand/collapse on the latest stable/master
](#132759)

#128082 updated the `expansionCallback` and also the `ExpansionPanel` sample in the Flutter gallery but not the API example. 

This PR fixes the API example and adds tests.
@your-diary
Copy link

@justinmc
Thank you for your suggestion.
As I believe there is a wider problem rather than one specific to this PR, I submitted #133025.

@Francesco-FL
Copy link

I was running final tests on an app when I suddenly noticed that the tabs weren't opening anymore. I was sure I hadn't touched the script and it was unfortunate after hours of questioning and debugging to find that the bool had been flipped.

I'm a little concerned that in the future, out of nowhere, a bool that was fine up until then could be flipped, ending up breaking my code without me noticing.

I don't know the flutter update processes in detail, but I'll try to give an advice even if it's too late: maybe instead of inverting the bool you could change the variable name? In order to force the developer to notice the change.

(translated)

@PhilippS93
Copy link

This PR also breaks the flutter documentation, which must be adapted. See here for example: https://api.flutter.dev/flutter/material/ExpansionPanelList-class.html

@jbryanh
Copy link

jbryanh commented Jan 4, 2024

@your-diary I saw your #133025 and that it was dismissed and closed. Thanks for your effort to improve the process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. team Infra upgrades, team productivity, code health, technical debt. See also team: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ExpansionPanelCallback shows incorrect state while opening and closing ExpansionPanelList.
8 participants