Call resize_widget() when changing widget's visibility to ensure container size is updated.
Implement /widget_toggle.
Use /widget_toggle maininv instead of ?INVENTORY macro in key bindings.