Skip to content

[bug]: FilterableMultiSelect shows blank row for custom load-more item when used with pagination support (v1.93.0) #21075

@prashantv3216

Description

@prashantv3216

When using FilterableMultiSelect with a custom itemToElement for a "Load More" item for pagination support, the row renders as a blank row and filtering it on the top of the list.

This seems to happen because Carbon’s internal logic filters out items to top and may ignore itemToElement for these items, even if filterItems correctly returns them.

version: @carbon/react: 1.93.0

Steps to Reproduce

  1. Use FilterableMultiSelect
  2. Pass items including a "Load More" object, for example:

const loadMoreItem = {
id: 'load-more',
text: 'Load More…',
label: 'Load More…',
disabled:true,
onClick: () => console.log('Load more clicked')
};

const items = [
{ id: 1, name: 'Item 1' },
{ id: 2, name: 'Item 2' },
loadMoreItem
];

  1. Use a custom itemToElement component:
    const CustomItem = ({ id, text, label, displayValue, onClick }) => {
    if (id === 'load-more') {
    return

    {text}
    ;
    }
    return {displayValue};
    };

  2. Set filterItems so the load-more item is always included:
    filterItems={(items, { inputValue }) =>
    items.filter(item =>
    item.id === 'load-more' || itemToString(item).toLowerCase().includes(inputValue.toLowerCase())
    )
    }

Environment
React 18
@carbon/react v1.93.0
Browser: Chrome 115+

Expected Behavior

  1. "Load More" item jumps to the top of the list and it appears as blank option.
  2. This occurs even though filterItems returns the item and itemToElement is defined.

Expected Behavior

  1. The custom "Load More" item should render reliably as a row using itemToElement.
  2. It should remain at the bottom of the list, regardless of filtering.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions