[BUG] PopupMenu direction needlessly changed

On the current dev branch, line 916 of juce_PopupMenu.cpp, in the struct MenuWindow final : public Component struct, there is some logic which I would consider a bug. It breaks convention for popup menus at large, and also goes against the intention of the option which sets the preferred popup direction.

y = target.getCentreY() > parentArea.getCentreY() ? jmax (parentArea.getY(), target.getBottom() - heightToUse) + border : target.getY() - border;

This is setting a sub menus popup direction based on where the item in the parent menu is on screen. It is not evaluating if the submenu has room to fit in the preferred direction from this point, it is simply evaluating if the point is above or below the halfway point of the screen.

This produces the current menu chain, you can see it flip-flopping direction around the center of the screen:

If we change that line to y = target.getY() - border; we get a normal looking menu:

Even with this configuration, if we run out of room toward the bottom of the screen, it will move as required:

Can we please get this logic removed? With larger and larger screens on the market, this only serves to annoy.

3 Likes