-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ngbModal after open focus on close button #2814
Comments
Great, this is the intended behaviour! What would you expect otherwise? |
As commented, we need to move focus to within modal for accessibility reasons / proper keyboard navigation. By default we focus the first focusable element within modal, which in your case is a close button. If you want to focus another element within modal you can add the |
I think this behaviour (when we open modal and see focus on close button) added excess UI. After some research I was found I found selector description in
And function I think it is not correct behaviour. |
I have to agree with @13bit. Not all modal windows should require a focused element. I have a window that provides a list of links to the user, and after upgrading from version 2.x the first link in the list is now highlighted. This does not make sense, I do not want to force the user's attention to one part of the window over another. A focused element indicates a prioritized action to the user, and this is not always desired. It should be the developer's option to apply focus to one element or another using the ngbAutofocus attribute, it shouldn't be mandatory. |
I also agree that opening a modal without focusing an element should be possible. Does focusing the modal itself solve the accessibility issues? |
@UniQP nope
@13bit One of the first thing that blind users need to know when landing on a modal is how to exit this modal.
@KalenGibbons this is exactly what this is about. The behaviour is not mandatory at all, it's just the default one which is configurable with usage of |
显得不圆润 |
I think not focusing on any element at the beginning is more fair. I also think it is easier for both of users and developers of this library. |
I think that for accessibility, the close button should be the default item focused. However, the option to change this should be available for developers. I actually got to this thread by the opposite case: my close buttons don't focus when the modal opens. I'm on Bootstrap 4.3.1, and when a button to open a modal is clicked, that button stays focused. This is fine default behavior, however, I cannot figure out how to change it. I currently have this event listener set in the onload function, per the docs:
Edit: I should note that keeping the focus on the button that opens it works as a pseudo close button, because when it's clicked again the modal is closed. However, visually focusing the close button for accessibility would be preferred, and I'd like tab navigation to continue within the modal, if any elements have a |
The Bootstrap 5 example does not auto-focus the close button https://getbootstrap.com/docs/5.1/components/modal/#live-demo |
Bootstrap has many a11y issues, it doesn't mean we have to reproduce them. If you need to change this, please use the Just put the focus wherever you need to → |
Bug description:
When I open modal window I see focus on close button.
Demo:
stackblitz
Versions of Angular, ng-bootstrap and Bootstrap:
Angular: 6.1.9
ng-bootstrap: 3.3.0
Bootstrap: 4.0.0
The text was updated successfully, but these errors were encountered: