Skip to content

Commit 3e3be91

Browse files
authored
fix(dropdowns.next): overrides floating ui's default RTL handling to prefer theme.rtl in menu (#1728)
1 parent 1f19180 commit 3e3be91

File tree

2 files changed

+115
-1
lines changed

2 files changed

+115
-1
lines changed

package-lock.json

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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 to Garden
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: [

0 commit comments

Comments
 (0)