-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
InputControl: Add optional Tooltip for inner input field #42726
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.
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.
Code changes look nice and clean.
One aspect I also wanted to consider is that this approach goes a little bit against out general intentions of keeping low-level components modular and composable. I thought about exposing a renderInputWrapper
prop that could be customised to include a Tooltip
when needed, but if we think that the Tooltip
functionality may be useful as a always-present feature of InputControl
, then we should leave it as is.
Also, another thought: to avoid nested tooltips, we should find a way to only render this tooltip if there aren't any other parent Tooltips
in the virtual DOM tree — which is being discussed in #42630
3d18f55
to
a858d70
Compare
I think this could be handy to have around.
Agreed. I'd like to tackle that within a follow-up once we have mechanism to achieve it e.g. a disable flag via context etc. |
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.
While reviewing this PR, I also considered, as an alternative to exposing showTooltip
and tooltipText
, a more generic tooltipProps
prop which we would just forward to the Tooltip
component, but then I came to the conclusion that it's not ideal in this scenario, since we may not want to expose all Tooltip
's props to the consumer of InputControl
.
I don't have any further feedback on this PR at the moment — I guess the next step would be to understand in #42661 if this is the way to go. If that's the case, I'd argue that we may want to add some unit tests for tooltip functionality and mark this PR as ready for review — at that point, I'll give it a final round of review & testing. |
Closing this old PR. If we come back to this or a similar approach it can be reopened. |
Related:
What?
Adds the ability to provide a tooltip for the
InputControl
's inner input field.Why?
This helps avoid the possibility of nested tooltips when the
InputControl
has an interactive prefix or suffix which might have its own tooltip.How?
showTooltip
&tooltipText
props to theInputControl
APIshowTooltip
is true along withtooltipText
or a stringlabel
, the innerInputField
is wrapped in its ownTooltip
Tooltip
theInputField
is wrapped in adiv
to avoid issuesTesting Instructions
InputControl
component displays the same on trunk as this PR (with or withoutshowTooltip
enabled)showTooltip
in the story controls and confirm the tooltip displays both on hover and via keyboard focustooltipText
value via story controls and confirm that text is used in the tooltip.InputControl
and confirm TooltipsInputControl
still function/look correct e.g.UnitControl
etc.Screenshots or screencast
Screen.Recording.2022-08-01.at.5.21.34.pm.mp4
Original demo without custom tooltip text support
Screen.Recording.2022-07-27.at.5.19.01.pm.mp4