Skip to content

Commit

Permalink
ui.js: fix duplicate event on mouse click
Browse files Browse the repository at this point in the history
On clicks, the YouTube app generates key events with keyCode 13 ("OK
button). We should not be sending our own click events for these, as
they already exist.
  • Loading branch information
throwaway96 committed Mar 29, 2024
1 parent 9b70578 commit b62505d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ function createOptionsPanel() {
navigate(ARROW_KEY_CODE[evt.keyCode]);
} else if (evt.keyCode === 13) {
// "OK" button
document.querySelector(':focus').click();

// The YouTube app generates these "OK" events from clicks (including
// with the Magic Remote), and we don't want to send a duplicate click
// event for those. It seems isTrusted is only true for "real" events.
if (evt.isTrusted === true) {
document.activeElement.click();
}
} else if (evt.keyCode === 27) {
// Back button
showOptionsPanel(false);
Expand Down

0 comments on commit b62505d

Please sign in to comment.