Skip to content

Commit cc6318f

Browse files
committed
chore: update floating ui platform method isRTL to always return false
1 parent ce407db commit cc6318f

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

packages/dropdowns.next/src/elements/menu/MenuList.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@ import {
1515
toFloatingPlacement,
1616
toMenuPosition
1717
} from './utils';
18-
import { Placement, autoUpdate, flip, offset, size, useFloating } from '@floating-ui/react-dom';
18+
import {
19+
Placement,
20+
autoUpdate,
21+
platform,
22+
flip,
23+
offset,
24+
size,
25+
useFloating
26+
} from '@floating-ui/react-dom';
1927
import { IMenuListProps, PLACEMENT } from '../../types';
2028
import { StyledFloatingMenu, StyledMenu } from '../../views';
2129
import { createPortal } from 'react-dom';
@@ -58,6 +66,14 @@ export const MenuList = forwardRef<HTMLUListElement, IMenuListProps>(
5866
update,
5967
floatingStyles: { transform }
6068
} = useFloating<HTMLElement>({
69+
platform: {
70+
...platform,
71+
// Defers RTL determination to Garden at all times.
72+
// References:
73+
// - https://github.com/floating-ui/floating-ui/issues/1530
74+
// - https://github.com/floating-ui/floating-ui/blob/master/packages/dom/src/platform/isRTL.ts#L3
75+
isRTL: () => theme.rtl
76+
},
6177
elements: { reference: triggerRef?.current, floating: floatingRef?.current },
6278
placement: floatingPlacement as Placement,
6379
middleware: [

packages/dropdowns.next/src/elements/menu/utils.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,12 @@ export const toFloatingPlacement = (
7070
if (isRtl) {
7171
/* Map Floating-UI to RTL placements */
7272
const placementMapRtl: Record<string, FloatingPlacement> = {
73-
'top-start': 'top-end',
74-
'top-end': 'top-start',
7573
left: 'right',
7674
'left-start': 'right-start',
7775
'left-end': 'right-end',
7876
right: 'left',
7977
'right-start': 'left-start',
80-
'right-end': 'left-end',
81-
'bottom-start': 'bottom-end',
82-
'bottom-end': 'bottom-start'
78+
'right-end': 'left-end'
8379
};
8480

8581
retVal = placementMapRtl[retVal] || retVal;

0 commit comments

Comments
 (0)