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 with body scrolling - confusing/illogical focus behaviour and concept #34584

Open
patrickhlauke opened this issue Jul 26, 2021 · 1 comment

Comments

@patrickhlauke
Copy link
Member

The idea with the offcanvas is that it's conceptually a modal dialog that just happens to be styled differently. However, the examples with body scrolling https://getbootstrap.com/docs/5.0/components/offcanvas/#backdrop break this concept - focus isn't moved to the offcanvas when opened, and not maintained in the offcanvas.

What's the intended use case here? Making this a non-modal offcanvas dialog? (that can be open while the main page is also still active)

If so, this needs a lot more work (treating the offcanvas essentially as a completely separate page/zone, and implementing keyboard interactions (e.g. using Ctrl+F6 or similar) for the user to move focus from the page to the offcanvas and back again, and then within those, keep the focus cycle clean.

Particularly puzzled by the backdrop+body scrolling example...what use case is this trying to address?

@patrickhlauke
Copy link
Member Author

In the latest release, following #36717 (comment), the situation is slightly improved, but still not perfect:

  • all offcanvas cases now set focus to the offcanvas when it opens
  • offcanvas with backdrop, and offcanvas without explicit scrolling enabled, are now correctly modal and traps focus

The only oddity left is:

While focus is moved to the offcanvas, it is then not maintained inside it. However, the offcanvas still has aria-modal="true" which will lead to an odd situation where, when running with most recent screen readers, it will act as a modal (and hide the rest of the page from the user), but for keyboard users without SRs running, it won't.

screenshot showing the offcanvas with body scrolling, and developer tools highlighting that it has aria-modal=true

If we're really trying to implement a non-modal offcanvas panel, the offcanvas should also still keep focus, but implement something like Ctrl+F6 to jump back out - and then a matching Ctrl+F6 to jump back into the offcanvas.

Unfortunately, a good solid example implementation of a non-modal dialog is still not available on the APG w3c/aria-practices#102 ...

Alternatively, we should decide and document that an offcanvas with body scrolling is, in effect, a strange variant of an expand/collapse disclosure widget - but in that case, it should not be marked as role="dialog" aria-modal="true"

@patrickhlauke patrickhlauke added v6 and removed v5 labels Dec 25, 2022
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

2 participants