Skip to content

Commit

Permalink
fix(layout/collapse): icon direction in rtl mode (#52374)
Browse files Browse the repository at this point in the history
* fix: collapse icon position in rtl mode

* fix: layout sider icon position in rtl mode

* chore: remove rtl demo
  • Loading branch information
aojunhao123 authored Jan 13, 2025
1 parent 666d019 commit a771c25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/collapse/Collapse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const Collapse = React.forwardRef<HTMLDivElement, CollapseProps>((props, ref) =>
mergedExpandIcon(panelProps)
) : (
<RightOutlined
rotate={panelProps.isActive ? 90 : undefined}
rotate={panelProps.isActive ? (direction === 'rtl' ? -90 : 90) : undefined}
aria-label={panelProps.isActive ? 'expanded' : 'collapsed'}
/>
);
Expand Down
7 changes: 4 additions & 3 deletions components/layout/Sider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const Sider = React.forwardRef<HTMLDivElement, SiderProps>((props, ref) => {
};

// =========================== Prefix ===========================
const { getPrefixCls } = useContext(ConfigContext);
const { getPrefixCls, direction } = useContext(ConfigContext);
const prefixCls = getPrefixCls('layout-sider', customizePrefixCls);

const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);
Expand Down Expand Up @@ -171,9 +171,10 @@ const Sider = React.forwardRef<HTMLDivElement, SiderProps>((props, ref) => {
{trigger || <BarsOutlined />}
</span>
) : null;
const reverseIcon = (direction === 'rtl') === !reverseArrow;
const iconObj = {
expanded: reverseArrow ? <RightOutlined /> : <LeftOutlined />,
collapsed: reverseArrow ? <LeftOutlined /> : <RightOutlined />,
expanded: reverseIcon ? <RightOutlined /> : <LeftOutlined />,
collapsed: reverseIcon ? <LeftOutlined /> : <RightOutlined />,
};
const status = collapsed ? 'collapsed' : 'expanded';
const defaultTrigger = iconObj[status];
Expand Down

0 comments on commit a771c25

Please sign in to comment.