Panel: Ignore click event whose default has been prevented

Check whether the default on the event that would close the panel has been
prevented, and ignore it if so.

Fixes #6693
Unit tests: Make sure panel doesn't close upon a default-prevented click

Re: #6693
Panel: Use this._on() to attach closing click events.