Skip to content

Commit

Permalink
client/views: fix middle click prevention on buttons for modern browsers
Browse files Browse the repository at this point in the history
Browsers no longer fire the primary 'click' event for middle clicks.
Old way kept for compatibility as it doesn't hurt anything. All browsers
that support auxclick also have standardized MouseEvent.button values.
  • Loading branch information
po5 committed May 6, 2024
1 parent 337cdc0 commit 5e54caf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client/js/util/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,11 @@ document.addEventListener("click", (e) => {
e.preventDefault();
}
});
document.addEventListener("auxclick", (e) => {
if (e.target.getAttribute("href") === "" && e.button === 1) {
e.preventDefault();
}
});

module.exports = {
htmlToDom: htmlToDom,
Expand Down

0 comments on commit 5e54caf

Please sign in to comment.