Pier Angelo Vendrame pushed to branch tor-browser-102.9.0esr-12.5-1 at The Tor Project / Applications / Tor Browser
Commits:
-
4d9627da
by Dan Ballard at 2023-04-05T14:55:29+02:00
1 changed file:
Changes:
... | ... | @@ -517,6 +517,9 @@ class AboutTorConnect { |
517 | 517 | this.hide(this.elements.viewLogButton);
|
518 | 518 | }
|
519 | 519 | this.show(this.elements.cancelButton, true);
|
520 | + if (state.StateChanged) {
|
|
521 | + this.elements.cancelButton.focus();
|
|
522 | + }
|
|
520 | 523 | }
|
521 | 524 | |
522 | 525 | showOffline(error) {
|
... | ... | @@ -772,6 +775,28 @@ class AboutTorConnect { |
772 | 775 | this.beginAutoBootstrap(value);
|
773 | 776 | }
|
774 | 777 | });
|
778 | + |
|
779 | + // Delay the "Enter" activation of the given button from "keydown" to
|
|
780 | + // "keyup".
|
|
781 | + //
|
|
782 | + // Without this, holding down Enter will continue to trigger the button
|
|
783 | + // until the user stops holding. This means that a user can accidentally
|
|
784 | + // re-trigger a button several times. This is particularly bad when the
|
|
785 | + // focus gets moved to a new button, and the new button can get triggered
|
|
786 | + // immediately. E.g. when the "Connect" button is triggered it disappears
|
|
787 | + // and focus moves to the "Cancel" button.
|
|
788 | + for (const button of document.body.querySelectorAll("button")) {
|
|
789 | + button.addEventListener("keydown", event => {
|
|
790 | + if (event.key === "Enter") {
|
|
791 | + event.preventDefault();
|
|
792 | + }
|
|
793 | + });
|
|
794 | + button.addEventListener("keyup", event => {
|
|
795 | + if (event.key === "Enter") {
|
|
796 | + button.click();
|
|
797 | + }
|
|
798 | + });
|
|
799 | + }
|
|
775 | 800 | }
|
776 | 801 | |
777 | 802 | initObservers() {
|