Skip to content
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

BS Modal on mobile view, throwing error on close button click #41090

Closed
3 tasks done
alaksandarjesus opened this issue Dec 12, 2024 · 4 comments
Closed
3 tasks done

BS Modal on mobile view, throwing error on close button click #41090

alaksandarjesus opened this issue Dec 12, 2024 · 4 comments

Comments

@alaksandarjesus
Copy link

alaksandarjesus commented Dec 12, 2024

Prerequisites

Describe the issue

On Mobile View, click on the close button, we get

Blocked aria-hidden on an element because its descendant retained focus. ....

image

Reduced test cases

Can test in https://getbootstrap.com/docs/5.3/components/modal/#how-it-works

What operating system(s) are you seeing the problem on?

Windows

What browser(s) are you seeing the problem on?

Chrome

What version of Bootstrap are you using?

5.3

@ALiaoHaolong
Copy link

I met this too!

@julien-deramond
Copy link
Member

julien-deramond commented Dec 16, 2024

I can confirm the presence of this message while triggering the modals in our own documentation (but not all the times) in Chrome and Microsoft Edge. The message is not there on Firefox.

Example of error message:

modal/#live-demo:1 Blocked aria-hidden on an element because its descendant retained focus. The focus must not be hidden from assistive technology users. Avoid using aria-hidden on a focused element or its ancestor. Consider using the inert attribute instead, which will also prevent focus. For more details, see the aria-hidden section of the WAI-ARIA specification at https://w3c.github.io/aria/#aria-hidden.
Element with focus: button
Ancestor with aria-hidden: 
<div class="modal fade" id="exampleModalLong" tabindex="-1" aria-labelledby="exampleModalLongTitle"
  style="display: none;" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">flex<div class="modal-header"></div>flex<div class="modal-body"
        style="min-height: 1500px">
        <p>"This is some
          placeholder content to show the scrolling behavior for modals. Instead of repeating the text in the modal, we
          use an inline style to set a minimum height, thereby extending the length of the overall modal and
          demonstrating the overflow scrolling. When content becomes longer than the height of the viewport, scrolling
          will move the modal as needed."</p>
      </div>
      <div class="modal-footer">flex<button type="button" class="btn
          btn-secondary" data-bs-dismiss="modal">Close</button><button type="button" class="btn btn-primary">Save
          changes</button></div>
    </div>
  </div>
</div>

The error message advises to use the inert attribute instead of aria-hidden. Please note that the inert attribute is not available until Safari 15.5, and we still have to support Safari 12.

@bravedave
Copy link

bravedave commented Dec 17, 2024

reported here: #41005

@julien-deramond
Copy link
Member

Thanks @bravedave, hadn't spotted it was a duplicate. So I'm closing this one.

@julien-deramond julien-deramond closed this as not planned Won't fix, can't repro, duplicate, stale Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants