Skip to content
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

[Bug]: ComboBox does not display the full name for items with truncated text (eg.tooltip) when shouldFilterItem is true #18459

Open
2 tasks done
ottawajackwang opened this issue Jan 28, 2025 · 1 comment

Comments

@ottawajackwang
Copy link

Package

@carbon/react

Browser

Chrome

Package version

10.5.0

React version

18.2.0

Description

Using ComboBox from @carbon/react,
When the search box is empty, the item with truncated text shows the tooltip as expected.
Image
However, when you type something in the search box, the tooltip stops showing.
Image

Reproduction/example

https://stackblitz.com/edit/jwernaba-awct9mvr?file=src%2FApp.jsx

Steps to reproduce

load the above example,
type e in search box,
the list should be filtered to 3 items.
hover over on the third one, no tooltip would be showing.

App.jsx as follows:

import React from 'react';

import { ComboBox } from '@carbon/react';

export default function App() {
const items = [
{
id: 'option-0',
text: 'An example option that is really long to show what should be done to handle long text',
},
{
id: 'option-1',
text: 'Option 1',
},
{
id: 'option-2',
text: 'Option 2',
},
{
id: 'option-3',
text: 'Option 3 - a disabled item',
},
{
id: 'option-4',
text: 'Option 4',
},
{
id: 'option-5',
text: 'Option 5 really long to show what should be done to handle long text',
},
];

const comboBoxFilterCallback =({
inputValue,
item,
itemToString,
}) => {
const label = item.text;
const searchLabel = label?.toLocaleLowerCase() || '';

const searchToken = inputValue ? inputValue.toLocaleLowerCase() : '';

return searchLabel.includes(searchToken);

};
return (
<div
style={{
width: 300,
}}
>
<ComboBox
id="carbon-combobox"
items={items}
itemToString={(item) => (item ? item.text : '')}
titleText="ComboBox title"
helperText="Combobox helper text"
onChange={() => {}}
shouldFilterItem={comboBoxFilterCallback}
downshiftProps= {
{isOpen: true}
}
/>

);
}

Suggested Severity

None

Application/PAL

No response

Code of Conduct

@Kritvi-bhatia17
Copy link
Contributor

Just a side note: The same issue is occurring with the filterable multi-select as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants