-
-
Notifications
You must be signed in to change notification settings - Fork 79.2k
Expand keyboard advice for tooltips, clarify what manual trigger does in table
#25163
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
Merged
patrickhlauke
merged 4 commits into
twbs:v4-dev
from
patrickhlauke:v4-dev-docs-tooltip-a11y
Jan 2, 2018
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,6 +94,8 @@ The required markup for a tooltip is only a `data` attribute and `title` on the | |
| ##### Making tooltips work for keyboard and assistive technology users | ||
|
|
||
| You should only add tooltips to HTML elements that are traditionally keyboard-focusable and interactive (such as links or form controls). Although arbitrary HTML elements (such as `<span>`s) can be made focusable by adding the `tabindex="0"` attribute, this will add potentially annoying and confusing tab stops on non-interactive elements for keyboard users. In addition, most assistive technologies currently do not announce the tooltip in this situation. | ||
|
|
||
| Additionally, do not rely solely on `hover` as the trigger for your tooltip, as this will make your tooltips impossible to trigger for keyboard users. | ||
| {% endcallout %} | ||
|
|
||
| {% highlight html %} | ||
|
|
@@ -111,11 +113,11 @@ You should only add tooltips to HTML elements that are traditionally keyboard-fo | |
|
|
||
| ### Disabled elements | ||
|
|
||
| Elements with the `disabled` attribute aren't interactive, meaning users cannot hover or click them to trigger a tooltip (or popover). As a workaround, you'll want to trigger the tooltip from a wrapper `<div>` or `<span>` and override the `pointer-events` on the disabled element. | ||
| Elements with the `disabled` attribute aren't interactive, meaning users cannot focus, hover or click them to trigger a tooltip (or popover). As a workaround, you'll want to trigger the tooltip from a wrapper `<div>` or `<span>`, ideally made keyboard-focusable using `tabindex="0"`, and override the `pointer-events` on the disabled element. | ||
|
|
||
| <div class="tooltip-demo"> | ||
| {% example html %} | ||
| <span class="d-inline-block" data-toggle="tooltip" title="Disabled tooltip"> | ||
| <span class="d-inline-block" tabindex="0" data-toggle="tooltip" title="Disabled tooltip"> | ||
| <button class="btn btn-primary" style="pointer-events: none;" type="button" disabled>Disabled button</button> | ||
| </span> | ||
| {% endexample %} | ||
|
|
@@ -192,7 +194,7 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap | |
| <p>Base HTML to use when creating the tooltip.</p> | ||
| <p>The tooltip's <code>title</code> will be injected into the <code>.tooltip-inner</code>.</p> | ||
| <p><code>.arrow</code> will become the tooltip's arrow.</p> | ||
| <p>The outermost wrapper element should have the <code>.tooltip</code> class.</p> | ||
| <p>The outermost wrapper element should have the <code>.tooltip</code> class, as well as a <code>role="tooltip"</code>.</p> | ||
|
||
| </td> | ||
| </tr> | ||
| <tr> | ||
|
|
@@ -208,7 +210,11 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap | |
| <td>trigger</td> | ||
| <td>string</td> | ||
| <td>'hover focus'</td> | ||
| <td>How tooltip is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. `manual` cannot be combined with any other trigger.</td> | ||
| <td> | ||
| <p>How tooltip is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space.</p> | ||
| <p><code>'manual'</code> indicates that the tooltip will be triggered programmatically via the <code>.tooltip('show')</code>, <code>.tooltip('hide')</code> and <code>.tooltip('toggle')</code> methods; this value cannot be combined with any other trigger.</p> | ||
| <p><code>'hover'</code> on its own will result in tooltips that cannot be triggered via the keyboard, and should only be used if alternative methods for conveying the same information for keyboard users is present.</p> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td>offset</td> | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oxford comma in first sentence, please—
focus, hover, or click.