Skip to content
Snippets Groups Projects
Unverified Commit 760ae5c0 authored by Abhinav Kumar's avatar Abhinav Kumar Committed by GitHub
Browse files

fix: "Filter by room type" selectable in Rooms filter (#33507)

parent a15b925c
No related branches found
No related tags found
No related merge requests found
---
'@rocket.chat/ui-client': patch
'@rocket.chat/meteor': patch
---
Fixed an issue where "Filter by room type" was selectable in the Rooms filter.
......@@ -9,6 +9,7 @@ const initialRoomTypeFilterStructure = [
{
id: 'filter_by_room',
text: 'Filter_by_room',
isGroupTitle: true,
},
{
id: 'd',
......
......@@ -24,6 +24,7 @@ export type OptionProp = {
id: string;
text: string;
checked?: boolean;
isGroupTitle?: boolean;
};
/**
......
import { render, screen } from '@testing-library/react';
import MultiSelectCustomList from './MultiSelectCustomList';
it('should render options with correct checked state', () => {
render(
<MultiSelectCustomList
options={[
{ id: '1', text: 'Option 1', checked: true },
{ id: '2', text: 'Option 2', checked: false },
]}
onSelected={jest.fn()}
/>,
{ legacyRoot: true },
);
const option1 = screen.getByLabelText('Option 1');
expect(option1).toBeInTheDocument();
expect(option1).toBeChecked();
const option2 = screen.getByLabelText('Option 2');
expect(option2).toBeInTheDocument();
expect(option2).not.toBeChecked();
});
it('should not render group title as selectable option', () => {
render(
<MultiSelectCustomList
options={[
{ id: '1', text: 'Group title', isGroupTitle: true },
{ id: '2', text: 'Option 1', checked: false },
]}
onSelected={jest.fn()}
/>,
{ legacyRoot: true },
);
expect(screen.getByText('Group title')).toBeInTheDocument();
expect(screen.queryByRole('checkbox', { name: /Group title/i })).not.toBeInTheDocument();
const option1 = screen.getByLabelText('Option 1');
expect(option1).toBeInTheDocument();
expect(option1).not.toBeChecked();
});
......@@ -40,8 +40,8 @@ const MultiSelectCustomList = ({
)}
{filteredOptions.map((option) => (
<Fragment key={option.id}>
{!option.hasOwnProperty('checked') ? (
<Box mi={12} mb={4} fontScale='p2b' color='default'>
{option.isGroupTitle || !option.hasOwnProperty('checked') ? (
<Box mi='x10' mb={4} fontScale='p2b' color='default'>
{t(option.text as TranslationKey)}
</Box>
) : (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment