Added event handling for panel collapse