Skip to content

Commit

Permalink
fix(dropdowns): overrides floating ui's default RTL handling to prefe…
Browse files Browse the repository at this point in the history
…r theme.rtl in menu (#1728)
  • Loading branch information
geotrev committed Mar 4, 2024
1 parent 544cf2b commit 8499182
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 1 deletion.
98 changes: 98 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion packages/dropdowns/src/elements/menu/MenuList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ import {
getFloatingPlacements,
getMenuPosition
} from '@zendeskgarden/react-theming';
import { autoPlacement, autoUpdate, flip, offset, size, useFloating } from '@floating-ui/react-dom';
import {
autoPlacement,
autoUpdate,
platform,
flip,
offset,
size,
useFloating
} from '@floating-ui/react-dom';
import { IMenuListProps, PLACEMENT } from '../../types';
import { StyledFloatingMenu, StyledMenu } from '../../views';
import { createPortal } from 'react-dom';
Expand Down Expand Up @@ -59,6 +67,14 @@ export const MenuList = forwardRef<HTMLUListElement, IMenuListProps>(
update,
floatingStyles: { transform }
} = useFloating<HTMLElement>({
platform: {
...platform,
// Defers RTL to Garden
// References:
// - https://github.com/floating-ui/floating-ui/issues/1530
// - https://github.com/floating-ui/floating-ui/blob/master/packages/dom/src/platform/isRTL.ts#L3
isRTL: () => theme.rtl
},
elements: { reference: triggerRef?.current, floating: floatingRef?.current },
placement: floatingPlacement,
middleware: [
Expand Down

0 comments on commit 8499182

Please sign in to comment.