-
Notifications
You must be signed in to change notification settings - Fork 4.7k
InputControl: Add optional Tooltip for inner input field #42726
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
Conversation
aaronrobertshaw
left a comment
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. |
ciampo
left a comment
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
InputControlhas an interactive prefix or suffix which might have its own tooltip.How?
showTooltip&tooltipTextprops to theInputControlAPIshowTooltipis true along withtooltipTextor a stringlabel, the innerInputFieldis wrapped in its ownTooltipTooltiptheInputFieldis wrapped in adivto avoid issuesTesting Instructions
InputControlcomponent displays the same on trunk as this PR (with or withoutshowTooltipenabled)showTooltipin the story controls and confirm the tooltip displays both on hover and via keyboard focustooltipTextvalue via story controls and confirm that text is used in the tooltip.InputControland confirm TooltipsInputControlstill function/look correct e.g.UnitControletc.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