Fixed first capability checkbox accidentally "clicked" when opening CUSTOM by space bar.

This commit is contained in:
hackademix 2020-05-31 18:13:14 +02:00
parent bbcf630866
commit 2b5e9bb226
1 changed files with 15 additions and 4 deletions

View File

@ -548,6 +548,20 @@ var UI = (() => {
debug("Wiring", root); debug("Wiring", root);
if (!root.wiredBy) { if (!root.wiredBy) {
root.addEventListener("keydown", e => this._keyNavHandler(e), true); root.addEventListener("keydown", e => this._keyNavHandler(e), true);
root.addEventListener("keyup", e => {
// we use a keyup listener to open the customizer from other presets
// because space repetion may lead to unintendedly "click" on the
// first cap checkbox once focused from keydown
switch(e.code) {
case "Space": {
let focused = document.activeElement;
if (focused.matches("tr .preset")) {
focused.closest("tr").querySelector(".preset[value='CUSTOM']").click();
e.preventDefault();
}
}
}
}, true);
root.addEventListener("click", this, true); root.addEventListener("click", this, true);
root.addEventListener("change", this, true); root.addEventListener("change", this, true);
root.wiredBy = this; root.wiredBy = this;
@ -590,11 +604,8 @@ var UI = (() => {
case "Space": case "Space":
if (focused.matches(".full-address")) { if (focused.matches(".full-address")) {
UI.openSiteInfo(row.domain); UI.openSiteInfo(row.domain);
} else if (focused.matches(".preset")) { } else {
if (e.code === "Enter") return; // let the popup handle closure if (e.code === "Enter") return; // let the popup handle closure
let custom = row.querySelector(".preset[value='CUSTOM']");
custom.focus();
custom.click();
} }
break; break;
case "Home": case "Home":