-
Notifications
You must be signed in to change notification settings - Fork 353
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
Draft tooltip design pattern #128
Comments
Fixed editorial issues in commit b1407a8. |
Yes, please do include guidance on using tooltip vs title attribute. |
@wendyabc, do you have some specific issues in mind that such guidance should address? |
This may already be in hand, but the current wording of the keyboard interactions reads as slightly ambiguous to me:
Should pressing Escape always dismiss the tooltip, or only dismiss the tooltip if it was invoked when the trigger element received focus? |
Yes, please link to the tooltip dialog pattern rather than the non-modal dialog section. |
Regarding tooltip vs title: at present, I am not aware of any way for a sighted keyboard-only user to see the content of the title attribute (unless they are using an AT).
The advantage of automatically opening the tooltip when the element receives focus is that this makes the tooltip very discoverable for keyboard users, but the (big) disadvantage is that keyboard power users very quickly become tired of them, even when there is a delay. The (big) advantage of providing a keyboard shortcut to open the tooltip is that users can choose when they want more information. The disadvantages are:
|
The first sentence of the tooltip pattern is:
So I think we should change that first sentence to something more like the following: |
What exactly is the point of having esc close the tooltip if it appears on hover/focus? As it would close when the control that invoked it is no longer hovered or focused (as mentioned in the note under keyboard interaction). |
Regarding having ESC close the tooltip, if a tooltip is shown (and focused) when the user types a keyboard shortcut (such as F1, Shift+F1, or F2), then ESC can be used to hide it. Alternatively, perhaps any Tooltip that is optionally shown/focused on a keyboard shortcut falls under the jurisdiction of the Tooltip dialog pattern (issue #85), even if it only contains text? |
Having ESC close the tooltip allows you to close it if it is distracting.
For example, if there were a really big tooltip attached to something which
obscures some other information you may want to see when filling in a form
field.
…On Tue, 23 May 2017 at 07:53 Carolyn MacLeod ***@***.***> wrote:
Regarding having ESC close the tooltip
<#128 (comment)>,
if a tooltip is shown (and focused) when the user types a keyboard shortcut
(such as F1 or F2), then ESC can be used to hide it.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#128 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABpQP5PUcJCVRG41WS5jMhxaeQWzhMjkks5r8vLkgaJpZM4KYHKf>
.
|
Agreed that that would be a nice thing to have. Note that the ESC key would go to the trigger element in that case, and not the tooltip, because according to the spec, "Tooltip widgets do not receive focus." |
The below note seems to violate a success criterion being proposed for WCAG 2.1:
See w3c/wcag21#75. There are accessibility reasons for the tooltip to persist while the tooltip itself has mouse hover. |
The above would be true where an item of content must be clicked on by mouse users to reveal the tooltip text; here the keyboard user would need an F1 or similar shortcut as suggested. But most tooltips I see involve a separate button beside the content, usually with an icon on them such as a ? character, or an I for information, or even the word Help. Depending on what interactivity the designers have chosen the keyboard user either focusses on it using the Tab key to reveal the tooltip, or they must press Enter or spacebar to reveal it. This kind of tooltip should be allowed for in this SC (I believe they can still be considered tooltips, as they perform the same function and behave the same way, they are just tooltips on the dedicated button instead of on the content itself). These cases use the element (or they should though many developers use an instead, but that's another story). Whether or the keyboard interaction is defined in the HTML spec, and keyboard users know how to operate buttons and links (pressing Enter works for both) so there is no need to provide extra info for it. |
Our use case is a code editor. Users can open a tooltip anywhere in the editor, to show the comment for a method or variable, the detailed text of a compiler error or warning, the details of a breakpoint for the current line, etc. Mouse users can see these tooltips by simply hovering over the function/variable name, error/warning indicator, or breakpoint annotation. Keyboard users need to navigate to the "trigger location" using the arrow keys, and then they can optionally open the tooltip by pressing F2. Note that the editor itself is the "trigger element", but it has focus the whole time, so focusIn cannot trigger the tooltip(s). It is the caret location that determines which tooltip is shown. It does not make sense to open them automatically when the caret reaches the intended trigger location because that gets incredibly annoying. If you are familiar at all with the Eclipse IDE, this is the way their code editor works. We used the same technique in our code editor because our Web IDE (Orion) was mostly written by Eclipse devs. :) An additional "quirk" of this technique is that a mouse user can hover to open a tooltip, and then, if they want it to take focus for whatever reason (some of the tooltips have buttons or links in them, which can be activated with keyboard or mouse), they simply type F2 and we give the tooltip focus. Esc closes it. One could argue that these are "dialog tooltips" and not "tooltips", or maybe they are a different beast altogether, but the typical mouse experience feels exactly like a tooltip, so we tried to keep the keyboard experience as close as possible. I could imagine an map or some other complex visualization working in a similar manner - the map has focus, the keyboard user navigates with arrow keys, and any time they want more info on the current location, they type F2 to get a tooltip. |
the |
I would like to see guidance about whether elements with |
I believe the tooltip pattern is intended to contain text-only content, @mcking65 can correct me if I am wrong. Please see #85 for discussion on the tooltip dialog pattern. |
Thanks @carmacleod! What about formatted text, e.g. bold or italics? Is the differentiating factor "interactivity", or is it closer to "anything that's not a plain string"? |
Hi, First, as I personally expect for these, all tooltips are never directly focusable, nor do they ever include any active elements. Defining this difference illustrates the difference between a tooltip and a non-modal dialog, both of which have very different requirements for accessibility. In my experience, there are typically 3 primary tooltip category types, standard tooltips, dynamic error tooltips, and dynamic responsive tooltips. The sub-variations fit within each of these. Standard Tooltips Behaviors: Standard tooltips are always directly invoked on the focused triggering element, even if the mechanism for doing so may differ between implementations. Also, when the tooltip is set, it remains static and unchanging for as long as the associated tooltip is rendered, even if the tooltip is animated to appear or disappear. Pressing the Escape key on the triggering element will remove the visual tooltip. All tooltips in general can only be invoked from focusable active elements, and focus should never be forcibly moved away from the triggering element when the tooltip is rendered. The simplest standard tooltip type consists of a focusable active element that references another element using aria-describedby, which causes the Description property to be set on the focused element in the accessibility tree. As an aside, the aria-description attribute can now be used to do the same thing in all mainstream browsers without having to reference an external element, even though this is technically an ARIA 1.3 addition. This capability is important in some circumstances. E.G. The use of aria-describedby can only reference elements that already exist within the DOM, and AT support degrades rapidly when aria-describedby is dynamically set on an element that already has focus, such as when a tooltip is dynamically created after a time delay such as 1.5 seconds after an element receives focus or is moused over. In contrast, aria-description can be set regardless if the tooltip is rendered in the DOM at the same time. There are 3 different standard tooltip types demonstrated at: http://whatsock.com/Templates/Tooltips/Internal/ The first tooltip displays a tooltip only after the triggering element is explicitly activated by pressing Enter/Space or by clicking/double-tapping it. The focused element is a toggle, and will dismiss the tooltip if activated again. Pressing Escape will similarly dismiss the tooltip; so too will tabbing away from the triggering element. Mouse users can mouse into and out of the tooltip, or directly click or tap it to dismiss it on touch devices. The second tooltip is triggered by an edit field, and will do so only when the field receives focus. The same pattern for dismissing the tooltip, however, is available by pressing Escape, tabbing away from the field, or mousing into and out of the tooltip or by clicking or tapping it. The third tooltip is rendered when the triggering element receives focus or is moused over. In this case, since the tooltip element does not exist in the DOM to be referenced using aria-describedby, the aria-description attribute is set to explicitly set the Description property in the accessibility tree instead, regardless if the tooltip is visually rendered at the same time. It must be noted that aria-description is not supported in IE11, and never will be. A variation of the above standard tooltip type can often be used to represent static inline form field errors after a form submission, where aria-describedby or aria-description is set on the form field in error before focus is set back to that element, thus causing it to be announced when the field receives focus. Dynamic Error Tooltips Behaviors: dynamic error tooltips are never directly invoked on the focused triggering element, but rather, only after focus moves away from the triggering element. Thus, aria-describedby and aria-description can never be relied upon for this purpose. When focus is set back to the form field where the dynamic error tooltip is displayed, the tooltip will automatically disappear to prevent obscuring surrounding content. Example: http://whatsock.com/Templates/Tooltips/Error%20(Inline)/ In this case, since an explicit description cannot be set, a live region is used instead to announce the error tooltip content when focus moves away from the required form field. The simplest and most unobtrusive way of doing this is to use aria-live="polite", which will cause the error to be announced without interrupting speech and preventing the next field in the tab order from being announced when it receives focus. At present, this works best in Firefox when using a screen reader like JAWS. Live region support in general is still buggy and not always announced as it should be in mainstream AT/browser combos such as JAWS in Chrome, which is disappointing. Dynamic Responsive Tooltips Behaviors: Dynamic responsive tooltips are always directly invoked on the focused triggering element, and change programmatically as the user interacts with the field. Example: http://whatsock.com/Templates/Tooltips/Help%20(Responsive)/ Though it seems intuitive that aria-describedby or aria-description can be used to handle this, this is only partially true. On desktops and laptops where focus is set on the triggering element, dynamically updating either aria-describedby or aria-description will fire a description_change event in the browser, thus causing the newly referenced content to be announced when the Description property changes in the accessibility tree. However, this will only occur when the Description changes on the currently focused element. As a result, this will not work at all when using a mobile platform like iOS where the act of typing into a virtual keyboard causes focus to be present elsewhere while the Description changes. As a result, it is necessary in this case as well to rely on a live region such as aria-live="polite" to announce the newly rendered tooltip content when it appears, which is also subject to the same drawbacks as described with the dynamic error tooltips. Hopefully this helps to clarify and break down the main differences a bit. All the best, |
Thanks for this fantastic breakdown. Question, how do you reconcile pressing escape with the fact that screen readers such as Jaws and NVDA, within a forms/focus mode, use this to exit that mode? Does this not mean that an SR user cannot dismiss the tooltip without negatively impacting their form-filling experience? I'm less worried about blind SR users, as they have a rare, but not non-zero need (think demos), to dismiss tooltips, but what about sighted SR users that do have such a need or those using magnification with speech where the above concern still holds? |
Unfortunately sighted screen reader users will experience the difference you mentioned, and I haven't found a graceful workaround for that. Basically there is a simple keydown event to detect when Escape is pressed, after which the tooltip is removed. However in the case of screen readers, the AT itself is hijacking the keypress in specific circumstances and does not pass the keystroke through to the focused control, which prevents it from doing what is expected. Some people have tried to overcome this by adding role=application around the control to force the user to stay put, but this is a very bad idea and should never be done for the purpose of hacking a screen reader that is hacking the page right back. |
Thanks @accdc for that writeup and the examples! I tried to condense those + some of my thoughts into a potential outline of examples for the tooltip design pattern. I'd be curious what you (and everyone else) think about it:
I didn't include the error tooltip or tooltip with dynamic content because while I think the work on notifications is really interesting, it doesn't seem relevant to the tooltip pattern. It seems like they'd fit better into a section on how to author notifications and live regions (which we should also add 😄). I also think they'd do better as inline text rather than tooltips -- the live region considerations would be the same, but then they don't have any of the UX problems introduced by tooltips. One other thing is I think we should consider control as a dismiss key in addition to escape because tooltips show up within dialogs, non-modal popups, menu dropdowns, and even combobox dropdowns with depressing regularity. If escape is standardized as the one single dismiss key, it'll cause problems in all of those cases. |
Notes from the meeting on 8/17: Example brainstorming:
Guidance section:General guidance section:
Behavior:
|
I noticed that screen readers don't seem to announce the role tooltip on this type of example
Or this
Also our working example has aria-labelledby and in that case it overrides any text in the button so in that case either use aria-describedby or have 2 ids in the labelledby, the button self reference and the tooltip
|
With which browser and screen reader does it not work? I have checked the examples with JAWS and NVDA and they work |
If the related element is not visible, should we close the tooltip? |
@tychenjiajun this is a very long thread. Can you please cite the prior comment you are referring to, or provide some more context?
|
Reakit Tooltip is a tooltip component that claims to follow this pattern. However, it has weird behaviour. When I tab on a reference to open the tooltip, then scroll the page's scrollbar using the mouse until the reference becomes invisible, the tooltip is still visible. Should scrolling dismiss the tooltip? |
@tychenjiajun said:
No, it should not be dismissed, and I wouldn't consider that weird. It seems to follow the guidance: you tabbed to it, so you have put focus on it, and scrolling the page is not removing focus from the reference. This Note might help:
|
Any updates on this tooltip? This tickets been open for quite sometime. |
@tychenjiajun, I just had a look at the Reakit tooltip you have now linked to in your comment, instead of just reading the behaviour you described. I see what you're talking about. I think what's happening is that this tip's behaviour is colliding with a few other things on this page:
I think those are both problems with the banner implementation, not with the tooltip. I guess the one thing that could be investigated is if the styling that is putting the tooltip over other content could result in other page oddities with regard to the tooltip display. Worth Reakit testing. |
Microsoft Windows closes tooltips with Key points are: "Escape" is irregular. We lack a general pop-up ARIA for "rich" popups. Tooltips should not be "rich". |
We have a use-case where we want to show the tooltip for a few seconds on initial page load and automatically dismiss it. After that the tooltip goes to regular behaviour and only appears on hover. Is this usage against the tooltip design pattern UX? |
The tooltip design pattern is at:
http://w3c.github.io/aria-practices/#tooltip
It is largely complete. Things to fix include:
page.
Open questions:
The text was updated successfully, but these errors were encountered: