Skip to content

Commit 45570d9

Browse files
fix(spatial-navigation): refocus available also to the close button of the error modal (#8819)
## Description This PR will make the refocus available not only to the buttons of the error modal but also to the close button of the error modal on the event of 'aftermodalfill'. ## Specific Changes proposed Allow the spatial-navigation to refocus the error modal when error modal appears. ## Requirements Checklist - [x] Feature implemented / Bug fixed - [ ] If necessary, more likely in a feature request than a bug fix - [ ] Change has been verified in an actual browser (Chrome, Firefox, IE) - [ ] Unit Tests updated or fixed - [ ] Docs/guides updated - [ ] Example created ([starter template on JSBin](https://codepen.io/gkatsev/pen/GwZegv?editors=1000#0)) - [ ] Has no DOM changes which impact accessiblilty or trigger warnings (e.g. Chrome issues tab) - [ ] Has no changes to JSDoc which cause `npm run docs:api` to error - [ ] Reviewed by Two Core Contributors
1 parent daf40bd commit 45570d9

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/js/spatial-navigation.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,20 @@ class SpatialNavigation extends EventTarget {
6262
this.player_.errorDisplay.on('aftermodalfill', () => {
6363
this.updateFocusableComponents();
6464

65-
// Focus the buttons of the modal
66-
if (this.focusableComponents.length > 1) {
67-
this.focusableComponents[1].focus();
65+
if (this.focusableComponents.length) {
66+
// The modal has focusable components:
67+
68+
if (this.focusableComponents.length > 1) {
69+
// The modal has close button + some additional buttons.
70+
// Focusing first additional button:
71+
72+
this.focusableComponents[1].focus();
73+
} else {
74+
// The modal has only close button,
75+
// Focusing it:
76+
77+
this.focusableComponents[0].focus();
78+
}
6879
}
6980
});
7081
}

0 commit comments

Comments
 (0)