carbon-design-system / carbon

A design system built by IBM
https://www.carbondesignsystem.com
Apache License 2.0
7.75k stars 1.8k forks source link

[MultiSelect]: Long options that don't fit on screen do not show hover text #9762

Closed eng618 closed 2 years ago

eng618 commented 3 years ago

Package

carbon-components, carbon-components-react

Browser

Chrome

Package version

latest

Description

When there is a selection in a MultiSelect that is long, the full text should show in a tooltip. Currently, that is not happening...at least by default. I did notice in the

https://react.carbondesignsystem.com/?path=/story/components-multiselect--filterable#usage

CodeSandbox example

https://codesandbox.io/s/multiselect-bug-o5gfi

Steps to reproduce

The same steps can be viewed with the above CodeSandbox link as well

Code of Conduct

tay1orjones commented 2 years ago

Refs https://github.com/carbon-design-system/carbon/issues/2966

Current guidance states a browser-based tooltip should be used:

Avoid having multiple lines of text in a dropdown. If the text is too long for one line, add an ellipsis (…) for overflow content, and accompany with a browser-based tooltip to show the full string of text.

This infers the use of title, but I don't know that we provide a way to set the title on the downshift items in the listbox. I think that's a minimum of what would be needed here. I'm not sure if MultiSelect ever properly handled this.

antoinog commented 2 years ago

Refs #2966

Current guidance states a browser-based tooltip should be used:

Avoid having multiple lines of text in a dropdown. If the text is too long for one line, add an ellipsis (…) for overflow content, and accompany with a browser-based tooltip to show the full string of text.

This infers the use of title, but I don't know that we provide a way to set the title on the downshift items in the listbox. I think that's a minimum of what would be needed here. I'm not sure if MultiSelect ever properly handled this.

7.25 Seemed to have it, as we lost the functionality on upgrading to 7.44 https://codesandbox.io/s/multiselect-bug-forked-ih9e8?file=/package.json image

tay1orjones commented 2 years ago

@antoinog I can't find any changes made to MultiSelect or the underlying primitives (downshift, etc) between these two versions.

Here's the full diff between tags: https://github.com/carbon-design-system/carbon/compare/v10.44.0...v10.45.0

I wonder if this could be related to a change made within the browser from an update

antoinog commented 2 years ago

@tay1orjones I think the issue was introduced in 10/7.32 carbon (react) 10/7.31 has tooltips https://codesandbox.io/s/multiselect-bugcarbon31-r87oq?file=/package.json

but not 32 https://codesandbox.io/s/multiselect-bugcarbon32-tlzo5?file=/package.json

https://github.com/carbon-design-system/carbon/compare/v10.31.0...v10.32.0

antoinog commented 2 years ago

@eng618 @tay1orjones Setting useTitleInItem to true works. Pre 32 maybe this was ignored? <MultiSelect id="b" useTitleInItem={true}

antoinog commented 2 years ago

https://react.carbondesignsystem.com/?path=/story/components-multiselect--filterable#usage The story has a Knob to Show Tooltip on hover, which sets useTitleInItem

tay1orjones commented 2 years ago

@antoinog Ah, yes I see that FilterableMultiSelect usage of useTitleInItem was changed slightly in #8178 v10.32.0, though I believe it's always been false by default. The change, linked here, placed the title on the span inside the checkbox wrapper. Previously it was passed directly to the Checkbox component.

Using 10.47.1 (latest) I see see the browser's title tooltip is displayed when useTitleInItem="true". Example codesandbox

Screen Shot 2021-11-08 at 9 12 25 PM

I'm going to close this as I think we've resolved the issue here, but let me know if not and we can reopen.