Menu

The Button Moved Before Your Finger Landed, and Your Click Handler Is Innocent
📰

The Button Moved Before Your Finger Landed, and Your Click Handler Is Innocent

DEV Community: css·Vladimir Elchinov·17 days ago
#MT55thvw
#devtocss#devto#dev#shift#shifts
Reading 0:00
15s threshold

The ticket says: "I pressed Cancel and it deleted my draft."

You open the code. The Cancel handler cancels. The Delete handler deletes. Nothing is crossed, nothing is mislabelled, and the click that arrived went to Delete because Delete was genuinely under that finger at the moment it landed. Both of you are describing the same event correctly and neither description contains the cause.

Something above those buttons changed size about eighty milliseconds earlier.

The browser already has a defence, and you have probably never configured it

There is a feature aimed squarely at this class of problem. MDN:

Scroll anchoring behavior adjusts scroll position to minimize content shifts.

And the line that explains why you have never thought about it:

Scroll anchoring behavior is enabled by default in any browser that supports it.

It works silently, so it is invisible until it is absent. Two things about it are worth holding.

It is one line to switch off.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.