FlexBox behaviour since 6.1.3


After updating juce to 6.1.3 I noticed the FlexBox behaviour changed.

Either I am using Flexbox incorrectly (and it accidentally worked before) or the new FlexBox behaviour is wrong.

Here is a simple juce project that should show a button and label (worked in juce 6.1.2). In 6.1.3 nothing shows up:

class MainComponent  : public juce::Component
        setSize (600, 400);

    ~MainComponent() override

    void paint (juce::Graphics& g) override
        // (Our component is opaque, so we must completely fill the background with a solid colour)
        g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));

    void resized() override
        juce::FlexBox box;
        box.flexDirection = juce::FlexBox::Direction::column;
        box.alignContent = juce::FlexBox::AlignContent::stretch;
        box.alignItems = juce::FlexBox::AlignItems::center;

    // Your private member variables go here...

    juce::TextButton button {"Button"};
    juce::Label label {"", "Label"};


I think you’re seeing the effects of this change:

Previously, FlexItems had a default ‘alignSelf’ value of ‘stretch’, and would therefore ignore the ‘alignItems’ setting of the FlexBox.

In your example, the button and label would have stretched to fill the width of the FlexBox. Now, the FlexItems respect the alignItems setting of the FlexBox and centre themselves inside the FlexBox instead. Because neither FlexItem has an explicit width, both items are given a width of ‘0’.

The simplest way to restore the desired behaviour is to use an alignItems of stretch instead of center.

This snippet is a simplified port of your example into CSS. It shows that JUCE’s new behaviour is the same as the CSS behaviour:


1 Like