←back to thread

293 points ulrischa | 1 comments | | HN request time: 0.213s | source
Show context
marcellus23 ◴[] No.42174016[source]
> All we had to do was change the isInvokedByMouse to check that screenX and screenY don't equal 0, rather than checking if they are greater than 0.

It's obviously extremely unlikely but what if the mouse is actually at 0,0 when the user clicks? I'm not very familiar with JS, is checking for != 0 really the best/only way to do this?

EDIT: actually upon going back, I realized I didn't fully process this sentence originally but it seems to address this:

> We should probably do further refactoring of the event handler function, since it's complicated by the fact that it also handles keydown events. For now, though, this fix will do just fine.

replies(3): >>42174129 #>>42174225 #>>42174311 #
nightpool ◴[] No.42174129[source]
But they're already checking for event.name == 'click' in the revised code. So why would you want to filter out some legitimate click events?
replies(2): >>42174182 #>>42174203 #
1. kulor ◴[] No.42174203[source]
Apply Chesterton's Fence principle and assume there are (hopefully) comments in the real code around why this has been put in place