Auto-Collapse Iconic Panels in Photoshop

To automatically show or hide iconic panels when working in Photoshop CS6 or newer, right-click on the panel tab and select Auto-Collapse Iconic Panels

This option makes it so that panels will automatically collapse back into an icon when you click anywhere outside of the panel.

You can also enable this feature by pressing Ctrl K (Windows), Command K (macOS), and from the Workspace tab, check the Auto-Collapse Iconic Panels checkbox.