-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Fix DropdownButton extra padding when alignDropdown: true #131183
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
…cific test updated
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Hello! Thanks a lot for the contribution:) Seems there are some test failures in the presubmit checks. Could you help fix this? |
Hello :), I've investigated the test failures and solved some of them. There is still one that causes all the failings due to the fact that it is checking if the DropdownButton's label is aligned with the first item from the DropdownMenuItem. When that extra padding was present, it was aligned. So I think that after removal of the padding, parts of the test are no longer required. But I'm not sure if this test modification approach is good. Shall I do it ? Those are the lines in the test that check the alignment:
Also, the differences: The following TestFailure was thrown running a test: |
|
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Sorry for the delay responding, we seem to have dropped the ball on this PR. Fundamentally, for each failing test we (you) have to carefully examine it and decide whether it's a bug in the test (i.e. the expectation was wrong and only passed because the old code was wrong, which the PR is fixing), or a regression caused by the PR (i.e. the expectation is correct, the old code was correct, and the PR is introducing a bug). One way to do this is to use |
| const double _kDenseButtonHeight = 24.0; | ||
| const EdgeInsets _kMenuItemPadding = EdgeInsets.symmetric(horizontal: 16.0); | ||
| const EdgeInsetsGeometry _kAlignedButtonPadding = EdgeInsetsDirectional.only(start: 16.0, end: 4.0); | ||
| const EdgeInsets _kAlignedButtonPadding = EdgeInsets.zero; |
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.
Hi! Just take another look, if we change this to EdgeInsets.zero. There will be no difference between _kAlignedButtonPadding and _kUnalignedButtonPadding . And with this change, it seems the padding would be useless in the Container on line 1481 because it will always be EdgeInsets.zero. Maybe we can just remove them all (The padding constants, padding variable and the padding in the Container).
I see another closed PR(#125193) by @Renzo-Olivares, so just wonder if he has any insights about this issue.
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.
Hi I took a quick look. I think completely removing the padding breaks alignedDropdown for something like this
ButtonTheme(
alignedDropdown: true,
child: DropdownButton<String>(
onChanged: (String? value) { },
value: 'foo',
items: const <DropdownMenuItem<String>>[
DropdownMenuItem<String>(
value: 'foo',
child: Text('foo'),
),
DropdownMenuItem<String>(
value: 'bar',
child: Text('bar'),
),
],
),
),I haven't been able to figure out why, but I haven't noticed any differences when turning this padding off specifically for DropdownButtonFormField like in my pr #125193 . I think this might be the safest route if we want to fix it this way since it won't affect the other DropdownButton.
I see alignedDropdown was introduced in #14849 by @HansMuller, so maybe he has more insight on this.
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.
It's true that I introduced #14849 five years ago :-). Although the after screenshot in the description does look like an improvement, changing the padding now would likely break many golden image tests and some layouts.
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.
I see. Turning off the padding only for DropdownButtonFormField makes sense to me. @OctavianMihaila Maybe we can fix the issue in this way?
|
What about this PR? When do you think to merge it? |
|
Hi @OctavianMihaila do you still plan on working on this PR? I made a suggestion regarding disabling the padding only in the case of |
|
(triage) I am going to close this one since there was no follow up. Feel free to reopen it if you find the time to work on this again. Thank you. |
Fixes #123783
Before:
After:
Removed that unnecessary padding from dropdown button's label by chaning this line in dropdown.dart:
const EdgeInsetsGeometry _kAlignedButtonPadding = EdgeInsetsDirectional.only(start: 16.0, end: 4.0);
to:
const EdgeInsets _kAlignedButtonPadding = EdgeInsets.zero;
Also, there was a test that verifies this padding's presence. I decided to modify it so that now it verifies if there is no padding (not sure if this was a good approach).
Pre-launch Checklist
///).