Skip to content

Commit 6d09c99

Browse files
authored
feat: Support zIndex (#258)
1 parent d2cbfac commit 6d09c99

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/Tooltip.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export interface TooltipProps extends Pick<TriggerProps, 'onPopupAlign' | 'built
3737
children?: React.ReactElement;
3838
popupVisible?: boolean;
3939
overlayInnerStyle?: React.CSSProperties;
40+
zIndex?: number;
4041
}
4142

4243
const Tooltip = (props: TooltipProps, ref) => {

tests/index.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const verifyContent = (wrapper, content) => {
1010
};
1111

1212
describe('rc-tooltip', () => {
13+
window.requestAnimationFrame = window.setTimeout;
14+
window.cancelAnimationFrame = window.clearTimeout;
15+
1316
describe('shows and hides itself on click', () => {
1417
it('using an element overlay', () => {
1518
const wrapper = mount(
@@ -145,4 +148,26 @@ describe('rc-tooltip', () => {
145148

146149
expect(wrapper.find('Trigger').props().popupMotion).toEqual({ motionName: 'bamboo-is-light' });
147150
});
151+
152+
it('zIndex', () => {
153+
jest.useFakeTimers();
154+
155+
const wrapper = mount(
156+
<Tooltip trigger={['click']} zIndex={903} overlay="Bamboo">
157+
<div className="target">Light</div>
158+
</Tooltip>,
159+
);
160+
wrapper.find('.target').simulate('click');
161+
162+
jest.runAllTimers();
163+
wrapper.update();
164+
165+
expect(wrapper.find('div.rc-tooltip').prop('style')).toEqual(
166+
expect.objectContaining({
167+
zIndex: 903,
168+
}),
169+
);
170+
171+
jest.useRealTimers();
172+
});
148173
});

0 commit comments

Comments
 (0)