-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Cannot tab to previously disabled button in modal #5050
Comments
This issue is related to / a subset of #5421 ('MODAL: Keyboard focus fail with dynamic content'). The problem again is that
So we have a problem in this case because the newly-focusable element (the 'OK' button) is later in the DOM than the element stored as the modal's last focusable element (the 'Cancel' button). Whenever we get to 'Cancel' and press tab, the keydown handler sees that we're on the element stored as the last focusable element in the modal, so it sends focus to the element stored as the first element of the modal (the first input box). Similarly, when you shift+tab from the first input box, focus gets manually sent back to the 'Cancel' button. We will have this problem with any element in a modal that is not initially focusable (whether it wasn't in the DOM at all or was initially disabled) and comes after the initial last focusable element in the DOM or before the initial first focusable element. (Note that you don't have this problem when we add a focusable element after your 'OK' button: Plunk.) Moreover, the tab trapping will fail entirely if we 'lose' the first or last focusable element (whether it's removed from the DOM or no longer focusable): Plunk. Workaround: As a user of the library, you can inject Proposed fix: In #5421, @dsuriano suggests calling |
I agree with the proposed fix - otherwise, we may have other strange accessibility issues. |
If you have a button that is disabled when the modal is opened and then becomes enabled later, you can't tab to the button.
Here's a plunk to reproduce it: http://plnkr.co/edit/8oCzQa3hPSloxnudxoG8?p=preview
Notice that focus never goes to the OK button.
The text was updated successfully, but these errors were encountered: