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
6 changes: 5 additions & 1 deletion src/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export type PickType =
| 'style'
| 'direction'
| 'notFoundContent'
| 'disabled';
| 'disabled'
| 'optionRender';

export type PanelProps<
OptionType extends DefaultOptionType = DefaultOptionType,
Expand Down Expand Up @@ -70,6 +71,7 @@ export default function Panel<
direction,
notFoundContent = 'Not Found',
disabled,
optionRender,
} = props as Pick<InternalCascaderProps, PickType>;

// ======================== Multiple ========================
Expand Down Expand Up @@ -159,6 +161,7 @@ export default function Panel<
expandIcon,
loadingIcon,
popupMenuColumnStyle: undefined,
optionRender
}),
[
mergedOptions,
Expand All @@ -172,6 +175,7 @@ export default function Panel<
expandTrigger,
expandIcon,
loadingIcon,
optionRender,
],
);

Expand Down
21 changes: 21 additions & 0 deletions tests/Panel.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,25 @@ describe('Cascader.Panel', () => {
fireEvent.click(selectOption);
expect(onChange).not.toHaveBeenCalled();
});

it('Should optionRender work in Panel', () => {
const { container, rerender } = render(
<Cascader.Panel
options={[{ label: 'bamboo', value: 'bamboo' }]}
optionRender={option => `${option.label} - test`}
/>,
);
expect(container.querySelector('.rc-cascader-menu-item-content')?.innerHTML).toEqual(
'bamboo - test',
);
rerender(
<Cascader.Panel
options={[{ label: 'bamboo', disabled: true, value: 'bamboo' }]}
optionRender={option => JSON.stringify(option)}
/>,
);
expect(container.querySelector('.rc-cascader-menu-item-content')?.innerHTML).toEqual(
'{"label":"bamboo","disabled":true,"value":"bamboo"}',
);
});
});
Loading