DAW shrinks window when calling setSize, but JUCE reports larger size, so content is drawn out of bounds

I’m working on a plugin which starts in a “basic mode” but has an “advanced” button which opens another section underneath the basic section when the user clicks it. When the advanced button is clicked, the plugin calls setSize to increase its height and maintain the appropriate aspect ratio. This works well in the standalone version, but some DAWs create a container window around the plugin and clamp the size of that window to fit on the screen at all times. When this happens, and the host shrinks the plugin window, the values returned by getWidth and getHeight in the resized callback do not update correctly, but return the original parameters passed to setSize. Thus, the plugin paints outside the bounds of the window and contents are clipped. As soon as I drag the bottom-right corner and resize the window, the width/height are correct again.

Here’s a screenshot of it painting outside the correct bounds:

Not sure if I’m doing something wrong here, but I’ve been struggling to find any information in the JUCE docs or other forum posts about how to get the “actual” container size (some posts seem to indicate that it’s not even possible, but they seem to be focused on getting the frame border of the container rather than the local bounds).

I couldn’t upload this image as part of the previous post since I’m a new user, but here’s what it looks like when it’s maximized to fit the screen’s width, before I click the “Advanced” button and open the lower section:

And after I manually drag the bottom-right resize corner (this is the intended behavior which I’d like to see instead of the glitch visible in the first post):

Any help on this would be amazing. I’m guessing many devs avoid have a vertical advanced section because of this bug.