-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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 the bug of DropdownButton popup widget position error #65605
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
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.
merged manually this changes into 1.22.0-10.0.pre.269 and it works fine for me
@HansMuller @goderbauer Is there any progress? |
@songfei This change is missing a test. Can you please add one? |
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.
This is also missing a test case that shows that everything now works correctly when the Navigator is not in fullscreen mode.
@@ -1178,8 +1178,11 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi | |||
TextStyle get _textStyle => widget.style ?? Theme.of(context).textTheme.subtitle1; | |||
|
|||
void _handleTap() { | |||
final RenderBox overlayBox = Overlay.of(context).context.findRenderObject() as RenderBox; | |||
final Offset overlayOffset = overlayBox.localToGlobal(Offset.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.
Instead of converting both to the global coordinate system, wouldn't it be enough to convert the itemBox to the coordinate system of the overlay by providing an ancestor argument to localToGlobal?
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.
What about this?
@goderbauer I add 2 test case and fix overlay problem, please review |
@@ -1178,8 +1178,11 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi | |||
TextStyle get _textStyle => widget.style ?? Theme.of(context).textTheme.subtitle1; | |||
|
|||
void _handleTap() { | |||
final RenderBox overlayBox = Overlay.of(context).context.findRenderObject() as RenderBox; | |||
final Offset overlayOffset = overlayBox.localToGlobal(Offset.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.
What about this?
), | ||
); | ||
|
||
final Finder buttonFinder = find.byKey(buttonKey).last; |
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.
Why the .last
? There should only be one button with this key.
); | ||
|
||
final Finder buttonFinder = find.byKey(buttonKey).last; | ||
final Finder popupFinder = find.byKey(const ValueKey<String>('c')).last; |
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.
Why the .last
?
await tester.pumpWidget( | ||
MaterialApp( | ||
home: Scaffold( | ||
// appBar: AppBar(title: const Text('Example')), |
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.
commented out code. Either remove or comment in if it is needed.
final Finder buttonFinder = find.byKey(buttonKey).last; | ||
final Finder popupFinder = find.byKey(const ValueKey<String>('c')).last; |
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.
Same question about .last
.
Looks like there's a merge conflict. Can you rebase this to the latest master and resolve the conflict? Thanks. |
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. |
This PR has not been updated in a while, so I am going to close it for now. If you would like to come back and work on this, feel free to re-open. Thank you! |
Description
This bug will happen when the Navigator is not full screen, the code:
Tests
above code ok
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.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read [Handling breaking changes].