diff --git a/src/components/Popover/Popover.tsx b/src/components/Popover/Popover.tsx index 4c1091cb96..1d844c9ea7 100644 --- a/src/components/Popover/Popover.tsx +++ b/src/components/Popover/Popover.tsx @@ -4,7 +4,9 @@ import {Xmark} from '@gravity-ui/icons'; import {Button} from '../Button'; import {Icon} from '../Icon'; +import type {PopupPlacement} from '../Popup'; import {Popup} from '../Popup'; +import {useDirection} from '../theme'; import type {QAProps} from '../types'; import {warnOnce} from '../utils/warn'; @@ -28,7 +30,7 @@ export const Popover = React.forwardRef(null); const closedManually = React.useRef(false); const shouldBeOpen = React.useRef(initialOpen); @@ -86,6 +89,14 @@ export const Popover = React.forwardRef(() => { + if (placement) { + return placement; + } + + return direction === 'rtl' ? ['left', 'bottom'] : ['right', 'bottom']; + }, [direction, placement]); + React.useImperativeHandle( ref, () => ({ @@ -120,7 +131,7 @@ export const Popover = React.forwardRef