Skip to content

Commit

Permalink
feat(Tooltip): add RTL support
Browse files Browse the repository at this point in the history
  • Loading branch information
kyletsang committed Aug 11, 2021
1 parent 9032b16 commit c82e133
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import classNames from 'classnames';
import * as React from 'react';
import PropTypes from 'prop-types';
import { useBootstrapPrefix } from './ThemeProvider';
import { useBootstrapPrefix, useIsRTL } from './ThemeProvider';
import { ArrowProps, Placement } from './types';
import { BsPrefixProps } from './helpers';
import { BsPrefixProps, getOverlayDirection } from './helpers';

export interface TooltipProps
extends React.HTMLAttributes<HTMLDivElement>,
Expand Down Expand Up @@ -89,14 +89,10 @@ const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(
ref,
) => {
bsPrefix = useBootstrapPrefix(bsPrefix, 'tooltip');
const isRTL = useIsRTL();

const [primaryPlacement] = placement?.split('-') || [];
let bsDirection = primaryPlacement;
if (primaryPlacement === 'left') {
bsDirection = 'start';
} else if (primaryPlacement === 'right') {
bsDirection = 'end';
}
const bsDirection = getOverlayDirection(primaryPlacement, isRTL);

return (
<div
Expand Down

0 comments on commit c82e133

Please sign in to comment.