Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: make Option's checkIcon slot render conditionally",
"packageName": "@fluentui/react-combobox",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ListboxContext } from '../../contexts/ListboxContext';
import { Option } from './Option';
import type { OptionProps } from './Option.types';
import { isConformant } from '../../testing/isConformant';
import { optionClassNames } from './useOptionStyles';

describe('Option', () => {
isConformant<OptionProps>({
Expand Down Expand Up @@ -222,4 +223,26 @@ describe('Option', () => {
expect(setActiveOption).toHaveBeenCalledTimes(1);
expect(setActiveOption).toHaveBeenCalledWith(optionData);
});

describe('checkIcon slot', () => {
it('renders the `checkIcon` slot by default', () => {
render(
<Option id="optionId" value="foo">
Option 1
</Option>,
);

expect(document.querySelector(`.${optionClassNames.checkIcon}`)).toBeTruthy();
});

it('should not render the `checkIcon` slot when passed `null`', () => {
render(
<Option id="optionId" value="foo" checkIcon={null}>
Option 1
</Option>,
);

expect(document.querySelector(`.${optionClassNames.checkIcon}`)).toBeFalsy();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const renderOption_unstable = (state: OptionState) => {

return (
<slots.root {...slotProps.root}>
<slots.checkIcon {...slotProps.checkIcon} />
{slots.checkIcon && <slots.checkIcon {...slotProps.checkIcon} />}
{slotProps.root.children}
</slots.root>
);
Expand Down