BR: Juce PopupMenu broken in JUCE 8.0.9 / iPadOS / AUv3?

To reproduce in Juce 8.0.9:

Create a new plugin project, with an iOS exporter, and enable AUv3 and stand-alone as wrappers.

Modify the editor.h class to add the following 2 components:

    juce::PopupMenu menu;
    juce::TextButton button;

Then modify the editor constructor to add:

    setSize (400, 300);
    menu.addItem(1, "option 1");
    menu.addItem(2, "option 2");
    menu.addItem(3, "option 3");
    
    button.setButtonText("click me");
    button.setBounds(20, 20, 200, 20);
    button.onClick = [this]
    {
        juce::PopupMenu::Options opts = juce::PopupMenu::Options().withParentComponent(this)
            .withTargetComponent(&button);
        menu.showMenuAsync(opts);
    };
    addAndMakeVisible(button);

If I now build this as stand-alone, the button appears, and when clicking it, the popup menu appears as well.

However in AUv3/iPadOS 18.6, the button appears, but the menu does not appear when clicking the button. Tested in AUM and Cubasis 3.

Does anyone else observe the same issue?

Thanks for reporting. This issue should be fixed by the following commit:

Please try it out and let us know if you’re still seeing any problems.

Thanks @reuk , that was quick! That commit seemed to have resolve the issue, thanks a lot. We’ll do some more testing and let you know of anything comes up.

1 Like

This is working now, though it seems like it still may have impacted some logic with opening the PopupMenu. If a ComboBox towards the bottom of the component opens a PopupMenu, it seems to be relegated to a very small height. IIRC the behavior used to be that the PopupMenu would prefer to open upwards if it couldn’t open downwards.

Closed (“Swing”):

Open:

On JUCE Develop 47d441787c9af0bbf5ba0a0694fe4f516be78be9 I see a similar issue. It shows an arrow and hides the other options (even there is enough space for display). And it does not align the top of the popup menu with the top of the combobox.

Besides, it does not respect the juce::PopupMenu::Options().withPreferredPopupDirection(juce::PopupMenu::Options::PopupDirection::upwards); in another combobox (it should pop upwards to avoid overlapping the sliders below). Again, I am sure there is enough space for pop upwards:

Those issue do not exist with JUCE 8.0.8 master.

As we are going to get a point release very soon, I wish this issue could be addressed before that.

Are you using withItemThatMustBeVisible()? If so, I think the behaviour you’re seeing is expected. The intended behaviour of this function is to position the visible item as close to the menu’s target area as possible, even if there’s space to expand the menu fully. If there’s not room to display the menu’s scroll-areas above and below the target area, then the menu will be positioned entirely outside the target area. The target area is frequently under the mouse when the menu is opened, and we want to avoid the menu scrolling on mouse-hover as soon as it’s opened.

Because withItemThatMustBeVisible() attempts to position the visible item over the target area, it’s expected that it ignores the preferred popup direction.

1 Like

Thanks for the timely reply. Yes, you are totally correct. withItemThatMustBeVisible is enabled by default and I did not fully understand it before adding it to my own code. I need to remove the line .withItemThatMustBeVisible (box.getSelectedId()) in my own LAF:

PopupMenu::Options LookAndFeel_V2::getOptionsForComboBoxPopupMenu (ComboBox& box, Label& label)
{
    return PopupMenu::Options().withTargetComponent (&box)
                               .withItemThatMustBeVisible (box.getSelectedId())
                               .withInitiallySelectedItem (box.getSelectedId())
                               .withMinimumWidth (box.getWidth())
                               .withMaximumNumColumns (1)
                               .withStandardItemHeight (label.getHeight());
}

@aqeelaadam The above info might be helpful.

Thanks @reuk and thanks for the ping @zsliu98! Removing withItemThatMustBeVisible fixed this for me. I guess because my ComboBox was towards the bottom of the component and the selected item was the first in the list, it was acting funky with withItemThatMustBeVisible set.

I do think some behavior changed unexpectedly here, even on desktop. On Mac at least, I believe that the PopupMenu used to be a separate window entirely and could float out over the bottom of the plug-in window. I’m not seeing this anymore. Not sure if this is WAI or not (IIRC the whole floating window thing was a source of pain for the JUCE team in the past). Either way it’s a relatively minor rendering issue, but was surprising to encounter after getting on 8.0.9.