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 gh-6693