-
Notifications
You must be signed in to change notification settings - Fork 715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow specifying zIndex for tooltip portals #1346
Changes from all commits
be6ed8d
3be9d36
a19f26a
0cc2449
a124ae0
c3cf1ed
5ba6651
84a040e
9b5743d
6087b6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,43 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import ResizeObserver from 'resize-observer-polyfill'; | ||
import { useTooltipInPortal } from '../src'; | ||
import { UseTooltipPortalOptions } from '../src/hooks/useTooltipInPortal'; | ||
|
||
interface TooltipWithZIndexProps { | ||
zIndexOption?: UseTooltipPortalOptions['zIndex']; | ||
zIndexProp?: UseTooltipPortalOptions['zIndex']; | ||
} | ||
|
||
const TooltipWithZIndex = ({ zIndexOption, zIndexProp }: TooltipWithZIndexProps) => { | ||
const { TooltipInPortal } = useTooltipInPortal({ | ||
polyfill: ResizeObserver, | ||
zIndex: zIndexOption, | ||
}); | ||
return <TooltipInPortal zIndex={zIndexProp}>Hello</TooltipInPortal>; | ||
}; | ||
|
||
describe('useTooltipInPortal()', () => { | ||
test('it should be defined', () => { | ||
expect(useTooltipInPortal).toBeDefined(); | ||
}); | ||
|
||
it('should pass zIndex prop from options to Portal', () => { | ||
const wrapper = shallow(<TooltipWithZIndex zIndexOption={1} />, { | ||
disableLifecycleMethods: true, | ||
}).dive(); | ||
const zIndex = wrapper.find('Portal').prop('zIndex'); | ||
expect(zIndex).toEqual(1); | ||
}); | ||
|
||
it('should pass zIndex prop from component to Portal', () => { | ||
const wrapper = shallow( | ||
<TooltipWithZIndex zIndexOption={1} zIndexProp="var(--tooltip-zindex)" />, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kangaechigai , is the setting for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed, but I wanted to illustrate that the prop overrides the option. |
||
{ | ||
disableLifecycleMethods: true, | ||
}, | ||
).dive(); | ||
const zIndex = wrapper.find('Portal').prop('zIndex'); | ||
expect(zIndex).toEqual('var(--tooltip-zindex)'); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this fix 🙏