Actually, I think these lines should just be about `.popover` instead of `.layer`. It should only not hide the popover if the other popover that was clicked is above (z-index wise) it. So try to change that here, and remove the other lines you added