diff --git a/src/js/spatial-navigation.js b/src/js/spatial-navigation.js index 46d0557836..dacb5e75a1 100644 --- a/src/js/spatial-navigation.js +++ b/src/js/spatial-navigation.js @@ -62,9 +62,20 @@ class SpatialNavigation extends EventTarget { this.player_.errorDisplay.on('aftermodalfill', () => { this.updateFocusableComponents(); - // Focus the buttons of the modal - if (this.focusableComponents.length > 1) { - this.focusableComponents[1].focus(); + if (this.focusableComponents.length) { + // The modal has focusable components: + + if (this.focusableComponents.length > 1) { + // The modal has close button + some additional buttons. + // Focusing first additional button: + + this.focusableComponents[1].focus(); + } else { + // The modal has only close button, + // Focusing it: + + this.focusableComponents[0].focus(); + } } }); }