Hi! There is currently a similar FR in the github issues – [FR]Option to auto hide outline panel when it collapses with main text · Issue #14 · theopavlove/obsidian-dynamic-outline. Please feel free to join the discussion. I’m still deciding on which logic to implement for these cases, so thank you for the snippet idea.
Also, an auto-hide for the editing mode sounds like a nice touch. I will think about integrating such logic to the plugin settings.