Extract document click logic and delay event subscription to avoid sspurious clicks