Overlay: Fixed bug that prevented in certain scenarios an overlay being opened through JS a second time

Fixes #6102
Merge pull request #6104 from pjackson28/fixoverlay

Overlay: Fixed bug that prevented in certain scenarios an overlay being opened through JS a second time