← All comics

Tap anywhere to close

#124 2 images

Ines asked for the shop's welcome pop-up to close wherever you tapped, and June shipped it on her way out. Closing it pressed the buy button underneath.

The mistake

The pop-up's dismiss handler is bound to a full-page overlay, but the tap that closes it is not stopped there — the event finishes its journey through the DOM and lands on whatever element sits underneath. Because the dismiss also removes the overlay before the browser dispatches the follow-up click, the coordinates resolve against the newly exposed page, so a tap meant only to close the modal fires the buy button behind it. Closing on tap needs preventDefault/stopPropagation on the dismissing event, or the overlay must remain in place until after the click cycle completes.

Share