ComboBox bug that causes flickering when opening a second ComboBox

ComboBoxes flicker when you open a ComboBox while a first ComboBox is already opened. The reason for this is that the PopupMenu is opened async, then dismissed in HidePopup, and then opened again in the mouseUp of the ComboBox. Showing the ComboBox in sync fixed the flickering problem, but might cause other problems?

Use case:
1 - Mouse down a ComboBox -> showPopup() causes async popup menu show.
2 - Mouse down another ComboBox -> showPopup() causes async popup menu show.
3 - The first ComboBox closes and calls comboBoxPopupMenuFinishedCallback -> hidePopup() is called and all
PopupMenus are dismissed (which should only be the first one).
4 - Mouse up on the second ComboBox -> Opens the second ComboBox again causing the flickering.

JUCE CODE:

    void ComboBox::showPopup()
    {
        PopupMenu menu;
        menu.setLookAndFeel (&getLookAndFeel());
        addItemsToMenu (menu);

        menu.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
                                                .withItemThatMustBeVisible (getSelectedId())
                                                .withMinimumWidth (getWidth())
                                                .withMaximumNumColumns (1)
                                                .withStandardItemHeight (label->getHeight()),
                            ModalCallbackFunction::forComponent (comboBoxPopupMenuFinishedCallback, this));
    }

    void ComboBox::hidePopup()
    {
    if (menuActive)
    {
        menuActive = false;
        PopupMenu::dismissAllActiveMenus();
        repaint();
    }
    }

    static void comboBoxPopupMenuFinishedCallback (int result, ComboBox* combo)
    {
    if (combo != nullptr)
    {
        combo->hidePopup();

        if (result != 0)
            combo->setSelectedId (result);
    }
    }

Video:

I would like to see it fixed too, I had reported the same issue a few months ago :

We are experiencing the same issue, could someone have a look?
The flickering looks quite unprofessional, we would appreciate a fix or at least a response telling us what you think about this.

Sorry, for the delay in answering posts. There was a bank holiday weekend in the UK and a lot of forum activity in the last few days. We are going through each post one by one but it may take a while until we look at each and every post.

This is definitely a JUCE bug. Let me see what the best fix for this is…

OK. I think this is fixed for ComboBoxes on develop with commit 66da02d.

1 Like

Will test this tomorrow, thank you.