FIX: multiple events triggering when using keyboard while focus is on a button
Keyboard events were triggering regardless of which element had focus, which led to surprising behaviour: if the play button was focused and spacebar got pressed, two playback toggle actions were triggered - one from the keyboard listener and one from the default button activation. This is fixed by ignoring spacebar presses in the custom listener if a button has focus. Also minor stylistic change break -> return
This commit is contained in:
parent
2be04e1e79
commit
3907d10755
@ -1663,11 +1663,14 @@ input[type="range"]::-ms-track {
|
|||||||
this._root.addEventListener('keydown', (event) => {
|
this._root.addEventListener('keydown', (event) => {
|
||||||
switch(event.key) {
|
switch(event.key) {
|
||||||
case " ":
|
case " ":
|
||||||
|
if(event.target.nodeName === "BUTTON") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.togglePlayback();
|
this.togglePlayback();
|
||||||
break;
|
break;
|
||||||
case "ArrowRight":
|
case "ArrowRight":
|
||||||
if(event.target === this._volumeSlider) {
|
if(event.target === this._volumeSlider) {
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
let ahead = this._controlSource.currentTime + 5;
|
let ahead = this._controlSource.currentTime + 5;
|
||||||
if(ahead > this._controlSource.duration) {
|
if(ahead > this._controlSource.duration) {
|
||||||
@ -1677,7 +1680,7 @@ input[type="range"]::-ms-track {
|
|||||||
break;
|
break;
|
||||||
case "ArrowLeft":
|
case "ArrowLeft":
|
||||||
if(event.target === this._volumeSlider) {
|
if(event.target === this._volumeSlider) {
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
let back = this._controlSource.currentTime - 5;
|
let back = this._controlSource.currentTime - 5;
|
||||||
if(back < 0) {
|
if(back < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user