Flow Panel unexpectedly moves element to another row

If I change the code in CodePen not to use a different font size in the palette than in the diagram:

const buildItemArray = (node: go.Node, isPalette?: boolean) => {
	const fontSize = 14;  // isPalette ? 12 : 14;

Then the results seem quite reasonable:

If you just want nodes to look smaller in the palette, just set its Diagram.initialScale to 0.8 or whatever.