Table component not stretching to fit in corner case

There is a case where the header of a table component that is set to stretch to fit will not fit correctly:

Uncomment this line in JUCE Demo, TableDemoComponent constructor:

Run JUCE Demo, choose Demo:Table Components
Stretch the demo window to 3 times its initial width
From left to right, make each column smaller in this order:
ID, Artist, Song, Album, Rating, Genre

Result:
At some point the Genre column will stop stretching, instead it will move to the left. Its right edge will move to the left. Making any change to the enclosing window size will cause the table header to snap back to the way it should be.

This only happens when the columns are resized in the order given. Any attempt to resize a column out of order will either not exhibit the bug, or cause the Genre column to stretch appropriately.

I see what you mean, but I don’t think it’s doing anything wrong.

When you shrink a column, it’s trying to make all the ones to the right fill the extra space. But if you make the window too wide, it can’t achieve that because the columns have a maximum width, so it’s making them as wide as it’s allowed to.

I suppose it could be a bit smarter and not let you drag a column to the left if that’d leave a gap at the right, but it a bit of a black art to get these column algorithms to work properly!