Skip to content

Commit 0c74505

Browse files
yellowryanthinkasanyli-jia-nan
authored
fix: dropdown submenu arrow wrong direction in rtl (#52885)
* fix: dropdown submenu arrow wrong direction in rtl * test: dropdown arrow direction in rtl mode * Update components/dropdown/dropdown.tsx Signed-off-by: lijianan <574980606@qq.com> --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: thinkasany <480968828@qq.com> Co-authored-by: lijianan <574980606@qq.com>
1 parent d5d9a36 commit 0c74505

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

components/dropdown/__tests__/index.test.tsx

+33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import type { TriggerProps } from '@rc-component/trigger';
3+
import ConfigProvider from '../../config-provider';
34

45
import type { DropDownProps } from '..';
56
import Dropdown from '..';
@@ -376,4 +377,36 @@ describe('Dropdown', () => {
376377
).toBeInTheDocument();
377378
expect(container.querySelector('.ant-dropdown-menu-item-extra')?.textContent).toBe(text);
378379
});
380+
381+
it('should show correct arrow direction in rtl mode', () => {
382+
const items = [
383+
{
384+
key: '1',
385+
label: 'sub menu',
386+
children: [
387+
{
388+
key: '1-1',
389+
label: '1rd menu item',
390+
},
391+
{
392+
key: '1-2',
393+
label: '2th menu item',
394+
},
395+
],
396+
},
397+
];
398+
399+
const { container } = render(
400+
<ConfigProvider direction="rtl">
401+
<Dropdown menu={{ items, openKeys: ['2'] }} open autoAdjustOverflow={false}>
402+
<a onClick={(e) => e.preventDefault()}>Cascading menu</a>
403+
</Dropdown>
404+
</ConfigProvider>,
405+
);
406+
expect(
407+
container.querySelector(
408+
'.ant-dropdown-menu-submenu-arrow .ant-dropdown-menu-submenu-arrow-icon',
409+
),
410+
).toHaveClass('anticon-left');
411+
});
379412
});

components/dropdown/dropdown.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from 'react';
2+
import LeftOutlined from '@ant-design/icons/LeftOutlined';
23
import RightOutlined from '@ant-design/icons/RightOutlined';
34
import type { AlignType } from '@rc-component/trigger';
45
import classNames from 'classnames';
@@ -252,14 +253,17 @@ const Dropdown: CompoundedComponent = (props) => {
252253
overlayNode = React.Children.only(
253254
typeof overlayNode === 'string' ? <span>{overlayNode}</span> : overlayNode,
254255
);
255-
256256
return (
257257
<OverrideProvider
258258
prefixCls={`${prefixCls}-menu`}
259259
rootClassName={classNames(cssVarCls, rootCls)}
260260
expandIcon={
261261
<span className={`${prefixCls}-menu-submenu-arrow`}>
262-
<RightOutlined className={`${prefixCls}-menu-submenu-arrow-icon`} />
262+
{direction === 'rtl' ? (
263+
<LeftOutlined className={`${prefixCls}-menu-submenu-arrow-icon`} />
264+
) : (
265+
<RightOutlined className={`${prefixCls}-menu-submenu-arrow-icon`} />
266+
)}
263267
</span>
264268
}
265269
mode="vertical"

0 commit comments

Comments
 (0)