Alternative of OverflowMode (TooltipHost in Fluentv8) in Tooltip component of Fluentv9? #28271
-
I want the tooltip component (fluentv9) to show up on hover, only when the text inside it is truncated. For Fluentv8's TooltipHost, there was a property called OverflowMode which handled the same. What's the corresponding alternative for it in Fluentv9's Tooltip? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@behowell, @khmakoto, could you please add your input on this discussion? {
isTruncated ? (
<Tooltip withArrow content={someContent} relationship="label">
<SomeComponent>{truncatedContent}</SomeComponent>
</Tooltip>
) : (
<SomeComponent>{someContent}</SomeComponent>
)} I don't think that truncation logic should be in the Tooltip because partners might use it differently. |
Beta Was this translation helpful? Give feedback.
-
Hi @aposingh1234, the v9 Tooltip doesn't have this functionality built in because of accessibility concerns. The tooltip in this case isn't accessible to touch or keyboard users (assuming the text is not focusable), which makes the full text content only available to mouse users. You might consider other options to show the text, such as a button to expand the container. That said, if you wanted to implement a tooltip that only showed when the text was truncated, it would be best to control the visible property of the Tooltip. Your code would listen to the [Conditionally rendering the Tooltip as in @ValentinaKozlova's example would work, but it would require you to listen for layout changes and re-render when the layout changes, which can be more difficult and worse for perf.] |
Beta Was this translation helpful? Give feedback.
Hi @aposingh1234, the v9 Tooltip doesn't have this functionality built in because of accessibility concerns. The tooltip in this case isn't accessible to touch or keyboard users (assuming the text is not focusable), which makes the full text content only available to mouse users. You might consider other options to show the text, such as a button to expand the container.
That said, if you wanted to implement a tooltip that only showed when the text was truncated, it would be best to control the visible property of the Tooltip. Your code would listen to the
onVisibleChange
event, and calculate thevisible
property based on whether the content is overflowing (compare clientWidth/clientHeigh…