# \[BUG\] PopupMenu direction needlessly changed

**URL:** <https://forum.juce.com/t/bug-popupmenu-direction-needlessly-changed/62200>\
**Category:** General JUCE discussion\
**Created:** [July 17, 2024, 2:15am UTC](https://forum.juce.com/t/bug-popupmenu-direction-needlessly-changed/62200 "2024-07-17T02:15:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fandusss](https://avatars.discourse-cdn.com/v4/letter/f/a4c791/32.png) [@Fandusss](https://forum.juce.com/u/Fandusss)\
**Post date:** [July 17, 2024, 2:15am UTC](https://forum.juce.com/t/bug-popupmenu-direction-needlessly-changed/62200/1 "2024-07-17T02:15:47Z")

</div>

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.

```auto
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:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/3/a/3a7635527081988e4686dda64233715348bc4ba1.png)

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/7/f/7f433df020edf8373b5c39e08d1862737b6537a5.png)

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/f/d/fdb25711a09e6181d1b80e38315de4e91f79d172.png)

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