Keep role="dialog" after closing modal/offcanvas if already in the markup#39941
Keep role="dialog" after closing modal/offcanvas if already in the markup#39941julien-deramond wants to merge 2 commits intomainfrom
role="dialog" after closing modal/offcanvas if already in the markup#39941Conversation
|
while i don't think it's necessarily needed, i can see how the idea of "our code cleans up after itself" works here. I would say it may actually be good/make sense for our documentation to say/show that you should ideally add |
So it would mean:
TBH, I prefer this approach where the DOM is correct right away, and the JS tries to help when it can. I hadn't suggested this approach because #30936 explicitly did the opposite. But if you're OK, and the rest of the team too, I can modify this PR in this direction. |
|
I think the one problem we had with having the |
|
Oh, I see! OK then, I won't have time to do it right away, but I'll try to apply everything we said in this PR. So I let it in draft until I have time to do it later on. Thanks a lot for the early feedback, Patrick. |
Description
This PR is the result of a discussion that happened in https://github.com/orgs/twbs/discussions/39933.
TL;DR: if a
role="dialog"is in the modal/offcanvas markup, our JavaScript will remove it when closing the element. The idea of this PR is to integrate a modification or our JavaScript behavior to keep this role if it is present in the markup.There was a scenario to handle that, which was to put back the
role="dialog"in the markup and doing nothing in the JavaScript by expecting users to correctly use it. But I like the enforcement rule that is present right as a modal/offcanvas can't be used without JavaScript right now anyway.So I preferred the approach in this PR that doesn't change anything in the current behavior, but allows some flexibility for folks still wanting to add the
role="dialog"in the markup for any reason.Please note that the documentation is not modified as it's still accurate (source: https://getbootstrap.com/docs/5.3/components/modal/#accessibility):
First, dear reviewers, what do you think of this approach, in terms of JavaScript and/or accessibility? As mentioned in the GH discussion, I deducted information in the history, but maybe it's wrong, and you have more history to share.
If we agree to go this way, is handling only
role="dialog"this way enough, or do you think we also should do the same thing foraria-modalwhich follows the same logic?While
Type of changes
Checklist
npm run lint)Live previews
Related GH discussion