Skip to content

Commit

Permalink
fix: rtl placement (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
MadCcc authored May 26, 2023
1 parent 4b2c468 commit 8fdc8af
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/SubMenu/PopupTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classNames from 'classnames';
import raf from 'rc-util/lib/raf';
import type { CSSMotionProps } from 'rc-motion';
import { MenuContext } from '../context/MenuContext';
import { placements } from '../placements';
import { placements, placementsRtl } from '../placements';
import type { MenuMode } from '../interface';
import { getMotion } from '../utils/motionUtil';

Expand Down Expand Up @@ -55,7 +55,9 @@ export default function PopupTrigger({

const [innerVisible, setInnerVisible] = React.useState(false);

const placement = { ...placements, ...builtinPlacements };
const placement = rtl
? { ...placementsRtl, ...builtinPlacements }
: { ...placements, ...builtinPlacements };

const popupPlacement = popupPlacementMap[mode];

Expand Down
35 changes: 35 additions & 0 deletions src/placements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,39 @@ export const placements = {
}
};

export const placementsRtl = {
topLeft: {
points: ['bl', 'tl'],
overflow: autoAdjustOverflow,
},
topRight: {
points: ['br', 'tr'],
overflow: autoAdjustOverflow,
},
bottomLeft: {
points: ['tl', 'bl'],
overflow: autoAdjustOverflow,
},
bottomRight: {
points: ['tr', 'br'],
overflow: autoAdjustOverflow,
},
rightTop: {
points: ['tr', 'tl'],
overflow: autoAdjustOverflow,
},
rightBottom: {
points: ['br', 'bl'],
overflow: autoAdjustOverflow,
},
leftTop: {
points: ['tl', 'tr'],
overflow: autoAdjustOverflow,
},
leftBottom: {
points: ['bl', 'br'],
overflow: autoAdjustOverflow,
}
};

export default placements;

0 comments on commit 8fdc8af

Please sign in to comment.