diff --git a/src/createSliderWithTooltip.jsx b/src/createSliderWithTooltip.jsx index f44ba44eb..35ca45c82 100644 --- a/src/createSliderWithTooltip.jsx +++ b/src/createSliderWithTooltip.jsx @@ -9,11 +9,13 @@ export default function createSliderWithTooltip(Component) { tipFormatter: PropTypes.func, handleStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.object)]), tipProps: PropTypes.object, + getTooltipContainer: PropTypes.func, }; static defaultProps = { tipFormatter(value) { return value; }, handleStyle: [{}], tipProps: {}, + getTooltipContainer: node => node.parentNode, }; state = { visibles: {}, @@ -33,6 +35,7 @@ export default function createSliderWithTooltip(Component) { tipFormatter, tipProps, handleStyle, + getTooltipContainer, } = this.props; const { @@ -53,6 +56,7 @@ export default function createSliderWithTooltip(Component) { return ( { // https://github.com/tmpvar/jsdom/commit/0cdb2efcc69b6672dc2928644fc0172df5521176 @@ -269,4 +269,17 @@ describe('createSlider', () => { expect(sliderOnAfterChange).toHaveBeenCalled(); expect(sliderOnAfterChange).toHaveBeenCalledTimes(1); }); + + it('the tooltip should be attach to the container with the id tooltip', () => { + const SliderWithTooltip = createSliderWithTooltip(Slider); + const tooltipPrefixer = { + prefixCls: 'slider-tooltip', + }; + const tooltipParent = document.createElement('div'); + tooltipParent.setAttribute('id', 'tooltip'); + const wrapper = mount( + document.getElementById('tooltip')} /> + ); + expect(wrapper.instance().props.getTooltipContainer).toBeTruthy(); + }); });