Panel: Track page from which external panel opens

Fixes gh-7099

I'm not sure how to write a test for this issue, since it's timing-related, and only seems to happen on FF.