Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: collapse default position in rtl #23445

Merged
merged 7 commits into from Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions components/collapse/Collapse.tsx
Expand Up @@ -40,7 +40,6 @@ export default class Collapse extends React.Component<CollapseProps, any> {

static defaultProps = {
bordered: true,
expandIconPosition: 'left' as CollapseProps['expandIconPosition'],
};

renderExpandIcon = (panelProps: PanelProps = {}, prefixCls: string) => {
Expand All @@ -66,10 +65,16 @@ export default class Collapse extends React.Component<CollapseProps, any> {
expandIconPosition,
} = this.props;
const prefixCls = getPrefixCls('collapse', customizePrefixCls);
let iconPosition;
if (expandIconPosition !== undefined) {
iconPosition = expandIconPosition;
} else {
iconPosition = direction === 'rtl' ? 'right' : 'left';
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

提到一个函数里。

const collapseClassName = classNames(
{
[`${prefixCls}-borderless`]: !bordered,
[`${prefixCls}-icon-position-${expandIconPosition}`]: true,
[`${prefixCls}-icon-position-${iconPosition}`]: true,
[`${prefixCls}-rtl`]: direction === 'rtl',
},
className,
Expand Down
Expand Up @@ -51,7 +51,7 @@ exports[`Collapse could override default openAnimation 1`] = `

exports[`Collapse rtl render component should be rendered correctly in RTL direction 1`] = `
<div
class="ant-collapse ant-collapse-icon-position-left ant-collapse-rtl"
class="ant-collapse ant-collapse-icon-position-right ant-collapse-rtl"
/>
`;

Expand Down