Ask HN: Button UI behaviour
I have observed a certain behaviour with on-screen buttons in a number of different environments (Android, PC, Browser) which perplexes me, and I'm hoping someone on here can explain it to me. I'm not a UI developer, but I did try googling before asking with no luck.
The behaviour is that when clicking on a button quickly, the button visually registers the click (by depressing or changing shading) but the action intended to be initiated by the button does not occur. This occurs intermittently - most of the time the button works normally. I suspect that it is occurring because of a debouncing algorithm which checks that the button is depressed for longer than a certain amount of time before counting it as "pressed". However, if that is the case, then why does the button appear to be depressed when it has not been clicked long enough to activate?
I'm sure I can't be the only person who has seen this phenomenon. Can any of the UI experts on here shed any light?
4 comments
[ 2.6 ms ] story [ 18.7 ms ] threadCodepen example: https://codepen.io/anon/pen/bvGrKY
Click the button as much as you like - after 200 milliseconds you'll get a single alert but the `:active` style always applies on click.
I can't think of an instance where I would dragging-and-dropping a button, maybe it was an anchor element or something else clickable, but perhaps it's an avenue to investigate.