mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 03:59:01 +08:00
fix: keep className given to expandIcon in Collapse component (#19160)
This commit is contained in:
parent
78b1f90e51
commit
3ac716d808
@ -45,14 +45,15 @@ export default class Collapse extends React.Component<CollapseProps, any> {
|
||||
|
||||
renderExpandIcon = (panelProps: PanelProps = {}, prefixCls: string) => {
|
||||
const { expandIcon } = this.props;
|
||||
const icon = expandIcon ? (
|
||||
const icon = (expandIcon ? (
|
||||
expandIcon(panelProps)
|
||||
) : (
|
||||
<Icon type="right" rotate={panelProps.isActive ? 90 : undefined} />
|
||||
);
|
||||
)) as React.ReactNode;
|
||||
|
||||
return React.isValidElement(icon)
|
||||
? React.cloneElement(icon as any, {
|
||||
className: `${prefixCls}-arrow`,
|
||||
className: classNames(icon.props.className, `${prefixCls}-arrow`),
|
||||
})
|
||||
: icon;
|
||||
};
|
||||
|
@ -27,6 +27,22 @@ describe('Collapse', () => {
|
||||
expect(wrapper.render()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should keep the className of the expandIcon', () => {
|
||||
const wrapper = mount(
|
||||
<Collapse
|
||||
expandIcon={() => (
|
||||
<button type="button" className="custom-expandicon-classname">
|
||||
action
|
||||
</button>
|
||||
)}
|
||||
>
|
||||
<Collapse.Panel header="header" />
|
||||
</Collapse>,
|
||||
);
|
||||
|
||||
expect(wrapper.find('.custom-expandicon-classname').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('should render extra node of panel', () => {
|
||||
const wrapper = mount(
|
||||
<Collapse>
|
||||
|
Loading…
Reference in New Issue
Block a user