fix: slider default tooltipplacement in rtl (#25909)

This commit is contained in:
xrkffgg 2020-07-30 17:04:13 +08:00 committed by GitHub
parent 2f99dd8c19
commit 309f63ae1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,6 +78,16 @@ const Slider = React.forwardRef<unknown, SliderSingleProps | SliderRangeProps>((
setVisibles(temp);
};
const getTooltipPlacement = (tooltipPlacement?: TooltipPlacement, vertical?: boolean) => {
if (tooltipPlacement) {
return tooltipPlacement;
}
if (!vertical) {
return 'top';
}
return direction === 'rtl' ? 'left' : 'right';
};
const handleWithTooltip: HandleGeneratorFn = ({
tooltipPrefixCls,
prefixCls,
@ -97,7 +107,7 @@ const Slider = React.forwardRef<unknown, SliderSingleProps | SliderRangeProps>((
prefixCls={tooltipPrefixCls}
title={tipFormatter ? tipFormatter(value) : ''}
visible={visible}
placement={tooltipPlacement || (vertical ? 'right' : 'top')}
placement={getTooltipPlacement(tooltipPlacement, vertical)}
transitionName="zoom-down"
key={index}
overlayClassName={`${prefixCls}-tooltip`}