Mac Sonoma - window disappears when open new window in front

My app works fine when not maximised.

I click a button to open a smaller Window (Document type). It appears in front of the main window (Document type). I do stuff then click the Close button and the main window is still there. Good!

Maximise the main window and click the button and the main window slides off the screen to the right and the new window slides in from the left.
Close the new window and there is nothing on the screen and the main window is minimized to the dock. Bad!
Is this a new thing with Sonoma?