Commit efa7d52
authored
Fix: Update PopupMenu position when layout changes (#157983)
This PR fixes an issue where PopupMenu doesn't update its position when
the screen layout changes (e.g. during rotation or window resizing).
## Changes
- Introduces `positionBuilder` instead of directly using position
- Calls positionBuilder after layout changes to get the updated position
- Adds tests to verify position updates correctly
## Related Issues
Fixes #152475 - PopupMenu retains wrong position on layout change
## Implementation Notes
This implementation uses a builder pattern to dynamically calculate
positions. This approach may be applicable to other popup widgets (like
DropdownButton mentioned in #156980) that have similar positioning
requirements.
<br>
<br>
<br>
<br>
<br>
*Replace this paragraph with a description of what this PR is changing
or adding, and why. Consider including before/after screenshots.*
*List which issues are fixed by this PR. You must list at least one
issue. An issue is not required if the PR fixes something trivial like a
typo.*
*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
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] 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].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md1 parent f9f42be commit efa7d52
File tree
2 files changed
+110
-18
lines changed- packages/flutter
- lib/src/material
- test/material
2 files changed
+110
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
852 | 852 | | |
853 | 853 | | |
854 | 854 | | |
855 | | - | |
| 855 | + | |
| 856 | + | |
856 | 857 | | |
857 | 858 | | |
858 | 859 | | |
| |||
870 | 871 | | |
871 | 872 | | |
872 | 873 | | |
873 | | - | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
874 | 877 | | |
875 | 878 | | |
876 | 879 | | |
877 | 880 | | |
878 | | - | |
| 881 | + | |
| 882 | + | |
879 | 883 | | |
880 | 884 | | |
881 | 885 | | |
| |||
955 | 959 | | |
956 | 960 | | |
957 | 961 | | |
958 | | - | |
959 | | - | |
| 962 | + | |
| 963 | + | |
960 | 964 | | |
961 | 965 | | |
962 | | - | |
| 966 | + | |
963 | 967 | | |
964 | 968 | | |
965 | 969 | | |
| |||
984 | 988 | | |
985 | 989 | | |
986 | 990 | | |
987 | | - | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
988 | 1015 | | |
989 | 1016 | | |
990 | 1017 | | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
991 | 1024 | | |
992 | 1025 | | |
993 | 1026 | | |
| |||
1047 | 1080 | | |
1048 | 1081 | | |
1049 | 1082 | | |
1050 | | - | |
| 1083 | + | |
| 1084 | + | |
1051 | 1085 | | |
1052 | 1086 | | |
1053 | 1087 | | |
| |||
1066 | 1100 | | |
1067 | 1101 | | |
1068 | 1102 | | |
| 1103 | + | |
| 1104 | + | |
1069 | 1105 | | |
1070 | 1106 | | |
1071 | 1107 | | |
| |||
1082 | 1118 | | |
1083 | 1119 | | |
1084 | 1120 | | |
| 1121 | + | |
1085 | 1122 | | |
1086 | 1123 | | |
1087 | 1124 | | |
| |||
1468 | 1505 | | |
1469 | 1506 | | |
1470 | 1507 | | |
1471 | | - | |
1472 | | - | |
1473 | | - | |
1474 | | - | |
1475 | | - | |
1476 | | - | |
1477 | | - | |
1478 | | - | |
1479 | | - | |
| 1508 | + | |
| 1509 | + | |
1480 | 1510 | | |
1481 | 1511 | | |
1482 | 1512 | | |
| |||
1502 | 1532 | | |
1503 | 1533 | | |
1504 | 1534 | | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
1505 | 1549 | | |
1506 | 1550 | | |
1507 | 1551 | | |
| |||
1513 | 1557 | | |
1514 | 1558 | | |
1515 | 1559 | | |
1516 | | - | |
| 1560 | + | |
1517 | 1561 | | |
1518 | 1562 | | |
1519 | 1563 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4387 | 4387 | | |
4388 | 4388 | | |
4389 | 4389 | | |
| 4390 | + | |
| 4391 | + | |
| 4392 | + | |
| 4393 | + | |
| 4394 | + | |
| 4395 | + | |
| 4396 | + | |
| 4397 | + | |
| 4398 | + | |
| 4399 | + | |
| 4400 | + | |
| 4401 | + | |
| 4402 | + | |
| 4403 | + | |
| 4404 | + | |
| 4405 | + | |
| 4406 | + | |
| 4407 | + | |
| 4408 | + | |
| 4409 | + | |
| 4410 | + | |
| 4411 | + | |
| 4412 | + | |
| 4413 | + | |
| 4414 | + | |
| 4415 | + | |
| 4416 | + | |
| 4417 | + | |
| 4418 | + | |
| 4419 | + | |
| 4420 | + | |
| 4421 | + | |
| 4422 | + | |
| 4423 | + | |
| 4424 | + | |
| 4425 | + | |
| 4426 | + | |
| 4427 | + | |
| 4428 | + | |
| 4429 | + | |
| 4430 | + | |
| 4431 | + | |
| 4432 | + | |
| 4433 | + | |
| 4434 | + | |
| 4435 | + | |
| 4436 | + | |
| 4437 | + | |
4390 | 4438 | | |
4391 | 4439 | | |
4392 | 4440 | | |
| |||
0 commit comments