-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Tooltip Text support for Views #8864
Conversation
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.
Looks very nice and simple tbh. Love it.
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.
LGTM so far!
I think we can benefit from adding some semantics here as well. From an accessibility perspective, the tooltip behavior is inconsistent between the platforms (tested Android, Catalyst) and in my opinion, not ideal on any at the moment.
On Android:
- When the screen reader focus is on the button, the tooltip gets announced (as a hint) in addition to the text (this is good)
- When long pressing to activate the hover with screen reader on, the toolitip appears visually but the screen reader does not note anything (this can be improved by using the Announce API imho)
MacCatalyst:
- The tooltip text never gets announced (should at least get announced as a hint)
- Same as Android
^ Those are my two cents on how it should behave from a basic accessibility standpoint. There are more complexities involved when we consider things like how to dismiss the tooltip message (the "mouse off" equivalent of screen reader - would probably need to consider the various types of announcement APIs that interrupt you vs. let you finish)
cc @PureWeen
On android, does it make sense that since the screenreader reads the text on focus, it's redundant to read it again on long press? I'm hesitant to change the default behavior here given the logical path to activating the tooltip through a screenreader would already read out the text before that action. For catalyst, what event would we ideally hook into for announcing the tooltip? focused? I think we could maybe open a new issue to track improvements to the screenreader experience around tooltips and keep this PR focused on the API wrapping each of the platform implementations. |
Now I am gonna be that guy... ToolTip or Tooltip? Should the T in Tip be uppercase or lowercase? |
src/Controls/src/Core/HandlerImpl/VisualElement/VisualElement.Impl.cs
Outdated
Show resolved
Hide resolved
How do i select the placement of the ToolTip? Colors etc? |
Tooltips are only supported in the Android API as of 26+. Prior to this, the TooltipCompat.SetToolTipText emulates the behavior however there is no TooltipCompat.GetToolTipText equivalent, so there's no way to actually 'get' the text that's currently set For now there's no valid way to test these cases, so we'll skip them for now.
I think for now we should open a follow up issue to assess how ToolTips are typically surfaced from an a11y standpoint. All of the code in this PR uses platform concepts of ToolTips so we're not inventing anything across any platforms. |
# Conflicts: # src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt # src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
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.
I would miss something like an IsOpen property, but as a basic implementation it works fine on Windows and macOS.
I agree but I don't think this is super easy to achieve with the platform APIs. I haven't found a great way to detect this on |
Ready for now, any a11y issues are platform-specific. See #8864 (comment)
Description of Change
Open questions
Everyone ok with an attached property?Yes they areIs
ToolTipProperty
an ok name? WinUI usesToolTipService
. I mainly went with ToolTipProperty because ofSemanticProperties
andAutomationProperties
. We don't really have anything suffixed withService
is
IToolTipElement
a valid name for something that has aToolTip
? Similar question here Context menu support for Windows and MacCatalyst #9174 (comment)Should
ToolTip
be a concrete class onToolTipProperty
and inherit fromElement
so you can set it in one go? We have cases for both. Right now we are following more of theFont
approach here. https://docs.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.tooltipservice?view=windows-app-sdk-1.1 . The main reason to do this is if we want to allow people to instantiate an entire ToolTip and if we think specifying via a tooltip class is easier for the user.API CHANGES
MAUI.Controls
MAUI.Core
Samples
Windows:
MacCatalyst:
Android:
Issues Fixed
Partially implements: #1889 There's no placement property here yet, the UIKit API's seem to allow this customization, nor do the Android API's.