Currently the PopMenu can overflow offscreen - in calculateContentWidth() with a long text and on smaller screens (e.g. iPhone SE) the contentFitWidth can easily be larger than screen width. The menu can also overflow offscreen even when its width is not larger than screen width due to overflow checks missing in calculateContentOrigin()
Description
I've changed calculateContentWidth() so that the maximum contentFitWidth is 90% of screen width (maxContentWidth)
Analogically in calculateContentOrigin() I've added minContentPos = 5% and maxContentPos = 95% of screen width, and clamped the popup between these positions.
The end result is that the popup menu can't overflow, max width is 90% of screen width, and there is always a 5% space between the edge of the screen and the menu. This is kinda arbitrary due to the existing "90% of screen" constraint already present, the constants can be changed (e.g. 100% width, 0% on the sides...), made configurable or whatever.
Checklist
Motivation and Context
Currently the PopMenu can overflow offscreen - in calculateContentWidth() with a long text and on smaller screens (e.g. iPhone SE) the contentFitWidth can easily be larger than screen width. The menu can also overflow offscreen even when its width is not larger than screen width due to overflow checks missing in calculateContentOrigin()
Description
The end result is that the popup menu can't overflow, max width is 90% of screen width, and there is always a 5% space between the edge of the screen and the menu. This is kinda arbitrary due to the existing "90% of screen" constraint already present, the constants can be changed (e.g. 100% width, 0% on the sides...), made configurable or whatever.