Open shendy-a8c opened 9 months ago
@shendy-a8c and @Automattic/helix - since you have the most context here, would you like to add this issue to your backlog?
We're adding this message after evaluating it in the Gamma weekly prioritization call.
IMO, we can include this as part of Helix backlog, but I will leave it upto @haszari to decide as I am still new to the team and would like to understand our acceptance criteria better 😄
We're happy to add this to our backlog, since we are heavy users of the tooltip component (and have some ideas to improve it!).
However I would be open to any other team picking this up too :)
Note at present, we wouldn't find this issue in our porter backlog search, since it doesn't have a relevant component/focus label (e.g. deposits, disputes, reporting etc). I'll manually add to our board so it doesn't get dropped.
An alternative here is to confirm that inline / css-in-js approach is required or recommended here, and document so there's no confusion.
Leaving this in Helix board as we're interested (and will ship more tooltips in payments widget project). Noting that this is not in our focus areas, other teams are welcome to pick it up.
@haszari I'll set focus as deposits, since you are taking care of this issue.
I had a dive into this and attempted replacing the existing inline maxWidth
with custom .scss
overrides. It works, but I'm not sure it is a better solution.
I tried both methods and like method 1 better.
Method 1 (current): JSX maxWidth
prop
<Tooltip maxWidth={'350px'} content="I am a long string that requires a larger max-width" />
<Tooltip maxWidth={ isTooltipContentLong ? '567px' : undefined } content="I am a long string that may require a larger max-width based on the boolean isTooltipContentLong" />
<Tooltip content="I am a normal tooltip that will inherit the default max-width" />
Method 2: CSS override method
<Tooltip id="tooltip-with-custom-id-1" content="I am a long string that requires a larger max-width" />
<Tooltip id={isTooltipContentLong ? "tooltip-with-custom-id-2" : undefined } content="I am a long string that may require a larger max-width based on the boolean isTooltipContentLong" />
<Tooltip content="I am a normal tooltip that will inherit the default max-width" />
#tooltip-with-custom-id-1 {
max-width: 350px;
}
#tooltip-with-custom-id-2 {
max-width: 567px;
}
inline which made it harder for 'child' components to override this max-width.
I might need some clarification of the exact pain-point/problem here.
Is it easier to override this max-width
via CSS or JS?
In this case, I think it may be more clear to define the maxWidth
alongside the tooltip content (in JSX), rather than require a unique class/ID and custom CSS.
E.g. in this file, we'd need to create an ID (or similar unique selector) for the 2 tooltips, since they share a classname, and write css to target each with a distinct max-width
.
One tooltip also seems to require a custom max-width
only when the balance is negative, so we'd need to pass this condition as a classname or other attribute.
I'm unsure if this is an easier or harder approach than passing a maxWidth
prop.
The maxWidth
prop is currently used 4 times in the codebase AFAICT
Lastly, here is an example with no max-width
set that illustrates the need for a default tooltip max-width:
vs the desired design
I can think of these cons of using maxWidth
prop in JS:
My take (broadly aligned with @shendy-a8c):
ToolTip
) that would address that problem.For me it's a combination of 2 principles:
Link
, ToolTip
, CurrencyValue
, Card
etc. I think this scenario is complicated by the fact that we have multiple ToolTip
wrapper components; I suspect we could use a generic ToolTip
directly in most cases.
Marking as low but if this annoys me again I may bump to medium.
Next steps might be:
I think the code should not have so much control over presentation, it should just say "I want to show a tooltip, here's the content". Then we wouldn't have issues trying to override the specifics in different use-cases of tooltip.
This is complicated by the fact that we have lots of custom wrappers for Tooltip
which IMO are not adding value, and make the prop-drilling problem more apparent.
Spun off from this discussion https://github.com/Automattic/woocommerce-payments/pull/8140#discussion_r1501976242, it might be better to set
TooltipBase
'smax-width
in CSS instead of inline which made it harder for 'child' components to override thismax-width
.