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

Offcanvas: activate focustrap when backdrop is enabled #36717

Merged
merged 7 commits into from Jul 14, 2022

Conversation

GeoSot
Copy link
Member

@GeoSot GeoSot commented Jul 11, 2022

@GeoSot GeoSot requested a review from a team as a code owner July 11, 2022 08:54
@GeoSot GeoSot added this to In progress in v5.2.0-stable via automation Jul 11, 2022
@GeoSot GeoSot force-pushed the gs/change-focustrap-activation-on-offcanvas branch from 7326d52 to 9c966fd Compare July 11, 2022 11:37
@julien-deramond
Copy link
Member

Added 658045e to tackle the 3rd point from the issue:

Also noticed that focus is not moved to either of the off-canvases (the docs nav, and the general nav), but remains on the toggle buttons. Not looked at the markup in depth, but suspect a tabindex="-1" is missing on them (compare to the working off-canvas examples https://getbootstrap.com/docs/5.2/components/offcanvas/).

To test it in the docs, simply focus the main header (keyboard), open both menus with 'Enter' and then press to 'Escape' to close them. 'Escape' didn't do anything before since offcanvases didn't get the focus. Now it's working.

@julien-deramond
Copy link
Member

If I have well understood the 2nd point in the issue, it is safe to remove aria-expanded="false" from the .navbar-togglers in the docs since offcanvases won't change the status and make an aria-expanded="true".
Done via d8f192d.

Copy link
Member

@julien-deramond julien-deramond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS part LGTM! I've added 2 commits to handle 2 other points mentioned in the issue. This PR will need also a review from @patrickhlauke.

v5.2.0-stable automation moved this from In progress to Reviewer approved Jul 12, 2022
@julien-deramond julien-deramond moved this from Reviewer approved to Review in progress in v5.2.0-stable Jul 12, 2022
js/tests/unit/offcanvas.spec.js Outdated Show resolved Hide resolved
@patrickhlauke
Copy link
Member

Looking good, and correctly addresses the issue #36596

At a higher level though, I'm wondering if we should just always enable focus trapping? Or, if we do want to allow non-modal offcanvases, we should document this clearly in the docs (currently it seems the docs are silent about focus behaviour at all) and also make sure that aria-modal="true" is only added when it's intended to be a modal offcanvas

@GeoSot
Copy link
Member Author

GeoSot commented Jul 13, 2022

At a higher level though, I'm wondering if we should just always enable focus trapping? Or, if we do want to allow non-modal offcanvases, we should document this clearly in the docs (currently it seems the docs are silent about focus behaviour at all) and also make sure that aria-modal="true" is only added when it's intended to be a modal offcanvas

Either way, an offcanvas that doesn't scroll or has a backdrop, behaves like modal, so I think is right for know.
BUT yes, we may, can discuss it for next releases

v5.2.0-stable automation moved this from Review in progress to Reviewer approved Jul 14, 2022
@patrickhlauke patrickhlauke merged commit 713d714 into main Jul 14, 2022
v5.2.0-stable automation moved this from Reviewer approved to Done Jul 14, 2022
@patrickhlauke patrickhlauke deleted the gs/change-focustrap-activation-on-offcanvas branch July 14, 2022 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v5.2.0-stable
  
Done
Status: Done
Development

Successfully merging this pull request may close these issues.

Docs: problems with the two off-canvas components for docs navigation and general navigation on small screen
3 participants