fix: menu position fix when dimensions change #3546
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The previous fix that I did that was recently merged (#3521) worked fine when I tested it (both with the example app and with the code from this snack: https://snack.expo.dev/@fyranollfyra/menu-with-keyboard).
But when I tested the released version with my own app where I originally discovered this bug, the bug was still there when changing width of my window.
So I started digging into the code some more and made it a bit simpler and removed unnecessary listeners since we now get the window layout when opening the menu (the same time as we get the anchor and menu layout as well).
I also cleaned up some of my previous code (
windowLayout.width
instead ofthis.state.windowLayout.width
) to be more in line how we use variables from state like we do formenuLayout
andanchorLayout
.Test plan
Make sure the menu position changes when changing the width and height of a window or when going from landscape to portrait on phone or tablet.
Also make sure the menu doesn't get behind the keyboard (on phone or tablet) with the snack above, and that the position of the menu is correct after keyboard is dismissed.