diff options
author | Patrick H. Lauke <redux@splintered.co.uk> | 2017-04-18 11:34:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-18 11:34:55 +0300 |
commit | 9a3e002e8f92b09d027083d3fc74750d6e56ef6e (patch) | |
tree | 0a9126ce1692b1f89030d92e5479a190085649cd /docs | |
parent | 6ae5fb12e6c996a6526250e8cb703b007e4213fc (diff) |
Add dropdown menu accessibility callout and fix <a> example
As the question often comes up about why Bootstrap does not do "true"
ARIA menus (with their `role="menu"` etc), add an admittedly lengthy
note (tl;dr because BS is generic, and ARIA menus are specific and quite
limiting).
Additionally, fixes up the `<a>` example for dropdown trigger, with the
missing `role="button"` and neutering the `href` (which would be useless
anyway since BS overrides the link-like nature of the `<a>` so it could
never be triggered/followed anyway)
Diffstat (limited to 'docs')
-rw-r--r-- | docs/components/dropdowns.md | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/docs/components/dropdowns.md b/docs/components/dropdowns.md index 0be8d4d74c..4da232b7d1 100644 --- a/docs/components/dropdowns.md +++ b/docs/components/dropdowns.md @@ -16,6 +16,16 @@ Dropdowns are toggleable, contextual overlays for displaying lists of links and Wrap the dropdown's toggle (your button or link) and the dropdown menu within `.dropdown`, or another element that declares `position: relative;`. Dropdowns can be triggered from `<a>` or `<button>` elements to better fit your potential needs. +{% callout info %} +### Dropdown menu accessibility + +The [<abbr title="Web Accessibility Initiative">WAI</abbr> <abbr title="Accessible Rich Internet Applications">ARIA</abbr>](https://www.w3.org/TR/wai-aria/) standard defines an actual [`role="menu"` widget](https://www.w3.org/TR/wai-aria/roles#menu), but this is specific to application-like menus which trigger actions or functions. <abbr title="Accessible Rich Internet Applications">ARIA</abbr> menus can only contain menu items, checkbox menu items, radio button menu items, radio button groups, and sub-menus. + +Bootstrap's dropdowns, on the other hand, are designed to be generic and applicable to a variety of situations and markup structures. For instance, it is possible to create dropdowns that contain additional inputs and form controls, such as search fields or login forms. For this reason, Bootstrap does not expect (nor automatically add) any of the `role` and `aria-` attributes required for true <abbr title="Accessible Rich Internet Applications">ARIA</abbr> menus. Authors will have to include these more specific attributes themselves. + +However, Bootstrap does add built-in support for most standard keyboard menu interactions, such as the ability to move through individual `.dropdown-item` elements using the cursor keys and close the menu with the <kbd>ESC</kbd> key. +{% endcallout %} + ### Single button dropdowns Any single `.btn` can be turned into a dropdown toggle with some markup changes. Here's how you can put them to work with either `<button>` elements: @@ -37,7 +47,7 @@ And with `<a>` elements: {% example html %} <div class="dropdown show"> - <a class="btn btn-secondary dropdown-toggle" href="https://example.com" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> + <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Dropdown link </a> |