plibither8 / refined-hacker-news

✨ Hacker News, but refined — Interface tweaks and features to make the HN experience better
MIT License
808 stars 34 forks source link

Clicks should only be intercepted if unmodified #26

Closed chris-morgan closed 5 years ago

chris-morgan commented 5 years ago

Take the “reply” link as an example. (There may be others, but I know this one.) If I didn’t use the left mouse button, or if I am holding down a modifier key, it should let the browser do its thing rather than showing the form inline. Ctrl-click, Cmd-click and middle-click, for example, will most likely open the link in a new tab.

This is the function we use at FastMail:

function isClickModified(event) {
    return !!event.button ||
        event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
}

… then almost all click handlers start with “if (isClickModified(event)) { return; }”.

plibither8 commented 5 years ago

Again, great suggestion! I'll implement this in the next few updates of the extension :)