Restore collapse class when a collapse is shown, and remove dependency on panel class

Fixes #10966