mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 11:39:28 +08:00
fix: collapse default position in rtl (#23445)
* fix: collapse default position in rtl * update snap * up * fix * fix * fix var * fix
This commit is contained in:
parent
9a43e439b3
commit
5e09660a3e
@ -7,7 +7,7 @@ import CollapsePanel from './CollapsePanel';
|
||||
import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
||||
import animation from '../_util/openAnimation';
|
||||
|
||||
export type ExpandIconPosition = 'left' | 'right';
|
||||
export type ExpandIconPosition = 'left' | 'right' | undefined;
|
||||
|
||||
export interface CollapseProps {
|
||||
activeKey?: Array<string | number> | string | number;
|
||||
@ -40,9 +40,16 @@ export default class Collapse extends React.Component<CollapseProps, any> {
|
||||
|
||||
static defaultProps = {
|
||||
bordered: true,
|
||||
expandIconPosition: 'left' as CollapseProps['expandIconPosition'],
|
||||
};
|
||||
|
||||
getIconPosition(direction: string = 'ltr') {
|
||||
const { expandIconPosition } = this.props;
|
||||
if (expandIconPosition !== undefined) {
|
||||
return expandIconPosition;
|
||||
}
|
||||
return direction === 'rtl' ? 'right' : 'left';
|
||||
}
|
||||
|
||||
renderExpandIcon = (panelProps: PanelProps = {}, prefixCls: string) => {
|
||||
const { expandIcon } = this.props;
|
||||
const icon = (expandIcon ? (
|
||||
@ -59,17 +66,13 @@ export default class Collapse extends React.Component<CollapseProps, any> {
|
||||
};
|
||||
|
||||
renderCollapse = ({ getPrefixCls, direction }: ConfigConsumerProps) => {
|
||||
const {
|
||||
prefixCls: customizePrefixCls,
|
||||
className = '',
|
||||
bordered,
|
||||
expandIconPosition,
|
||||
} = this.props;
|
||||
const { prefixCls: customizePrefixCls, className = '', bordered } = this.props;
|
||||
const prefixCls = getPrefixCls('collapse', customizePrefixCls);
|
||||
const iconPosition = this.getIconPosition(direction);
|
||||
const collapseClassName = classNames(
|
||||
{
|
||||
[`${prefixCls}-borderless`]: !bordered,
|
||||
[`${prefixCls}-icon-position-${expandIconPosition}`]: true,
|
||||
[`${prefixCls}-icon-position-${iconPosition}`]: true,
|
||||
[`${prefixCls}-rtl`]: direction === 'rtl',
|
||||
},
|
||||
className,
|
||||
|
@ -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"
|
||||
/>
|
||||
`;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user