Skip to content
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 popovers/tooltips to pass through flip prop #1443

Merged
merged 1 commit into from Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs/lib/Components/PopoversPage.js
Expand Up @@ -77,7 +77,16 @@ export default class PopoversPage extends React.Component {
offset: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
])
]),
// Whether to show/hide the popover with a fade effect
// (default: true)
fade: PropTypes.bool,
// Whether to flip the direction of the popover if too close to
// the container edge
// (default: true)
flip: PropTypes.bool,
}`}
</PrismCode>
</pre>
Expand Down
11 changes: 10 additions & 1 deletion docs/lib/Components/TooltipsPage.js
Expand Up @@ -88,7 +88,16 @@ export default class TooltipsPage extends React.Component {
PropTypes.func,
PropTypes.string,
PropTypes.object
])
]),
// Whether to show/hide the popover with a fade effect
// (default: true)
fade: PropTypes.bool,
// Whether to flip the direction of the popover if too close to
// the container edge
// (default: true)
flip: PropTypes.bool,
}`}
</PrismCode>
</pre>
Expand Down
3 changes: 3 additions & 0 deletions src/TooltipPopoverWrapper.js
Expand Up @@ -39,6 +39,7 @@ export const propTypes = {
]),
trigger: PropTypes.string,
fade: PropTypes.bool,
flip: PropTypes.bool,
};

const DEFAULT_DELAYS = {
Expand Down Expand Up @@ -312,6 +313,7 @@ class TooltipPopoverWrapper extends React.Component {
modifiers,
offset,
fade,
flip,
} = this.props;

const attributes = omit(this.props, Object.keys(propTypes));
Expand All @@ -337,6 +339,7 @@ class TooltipPopoverWrapper extends React.Component {
cssModule={cssModule}
onClosed={this.onClosed}
fade={fade}
flip={flip}
>
<div
{...attributes}
Expand Down
15 changes: 13 additions & 2 deletions src/__tests__/TooltipPopoverWrapper.spec.js
Expand Up @@ -236,7 +236,7 @@ describe('Tooltip', () => {
</TooltipPopoverWrapper>,
{ attachTo: container }
);

expect(isOpen).toBe(false);
target.dispatchEvent(new Event('touchstart'));
jest.runTimersToTime(20);
Expand All @@ -256,7 +256,7 @@ describe('Tooltip', () => {
</TooltipPopoverWrapper>,
{ attachTo: container }
);

expect(isOpen).toBe(true);
target.dispatchEvent(new Event('touchstart'));
jest.runTimersToTime(20);
Expand Down Expand Up @@ -315,6 +315,17 @@ describe('Tooltip', () => {
wrapper.unmount();
});

it('should pass down flip', () => {
const wrapper = mount(
<TooltipPopoverWrapper isOpen target="target" flip={false}>
Tooltip Content
</TooltipPopoverWrapper>
);

expect(wrapper.find(PopperContent).props().flip).toBe(false);
wrapper.unmount();
});

it('should not call props.toggle when disabled ', () => {
const props = createSpyObj('props', ['toggle']);
const event = createSpyObj('event', ['preventDefault']);
Expand Down