Skip to content

Commit

Permalink
Use TooltipTrigger instead of OverlayTrigger in Table plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Ming Xiao <mxiao@pivotal.io>
  • Loading branch information
Jonathan Berney authored and Ming Xiao committed Jul 13, 2018
1 parent f1547b8 commit b224729
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
19 changes: 11 additions & 8 deletions spec/pivotal-ui-react/table/plugins/cell-tooltip_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ describe('withCellTooltip', () => {
expect(tooltip).toHaveBeenCalledWith({isHeader: false}, data[1]);
});

it('does not render a tooltip', () => {
expect('.tooltip').not.toExist();
it('renders a hidden tooltip', () => {
expect('thead tr:eq(0) th:eq(0) .tooltip .tooltip-container').toHaveClass('tooltip-container-hidden');
expect('tbody tr:eq(0) td:eq(0) .tooltip .tooltip-container').toHaveClass('tooltip-container-hidden');
expect('tbody tr:eq(1) td:eq(0) .tooltip .tooltip-container').toHaveClass('tooltip-container-hidden');
});

it('renders an Icon for the first header', () => {
Expand All @@ -52,29 +54,30 @@ describe('withCellTooltip', () => {

describe('when hovering the first header', () => {
beforeEach(() => {
$('th:eq(0) .overlay-trigger').simulate('mouseOver');
$('tr:eq(0) th:eq(0) .tooltip').simulate('mouseOver');
});

afterEach(() => {
$('th:eq(0) .overlay-trigger').simulate('mouseOut');
$('tr:eq(0) th:eq(0) .tooltip').simulate('mouseOut');
});

it('renders a tooltip', () => {
expect('.tooltip').toHaveText('is header? true');
expect('thead th:eq(0) .tooltip .tooltip-container').toHaveClass('tooltip-container-visible');
expect('thead th:eq(0) .tooltip-content').toHaveText('is header? true');
});
});

describe('when hovering the first body row first column', () => {
beforeEach(() => {
$('tr:eq(1) td:eq(0) .overlay-trigger').simulate('mouseOver');
$('tr:eq(1) td:eq(0) .tooltip').simulate('mouseOver');
});

afterEach(() => {
$('tr:eq(1) td:eq(0) .overlay-trigger').simulate('mouseOut');
$('tr:eq(1) td:eq(0) .tooltip').simulate('mouseOut');
});

it('renders a tooltip', () => {
expect('.tooltip').toHaveText('is header? false');
expect('tr:eq(1) td:eq(0) .tooltip-content').toHaveText('is header? false');
});
});
});
16 changes: 8 additions & 8 deletions src/react/table/plugins/cell-tooltip.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// eslint-disable-next-line no-unused-vars
import React from 'react';
import {Tooltip} from '../../tooltip';
import {OverlayTrigger} from '../../overlay-trigger';
import {TooltipTrigger} from '../../tooltip';
import {Icon} from '../../iconography';

import {TablePlugin} from '../table-plugin';
Expand All @@ -14,22 +13,23 @@ export function withCellTooltip(Table) {
const {text, size, theme, showIcon} = tooltip({isHeader}, rowDatum) || {};
if (!text) return;

const overlay = (<Tooltip {...{size}}>{text}</Tooltip>);
const children = (
<OverlayTrigger {...{
<TooltipTrigger {...{
placement: 'top',
overlay,
theme
tooltip: text,
theme,
size,
trigger: 'hover'
}}>
<span className="overlay-trigger">
<span>
<span>{oldChildren}</span>
{showIcon && <Icon {...{
src: 'info_outline',
verticalAlign: 'baseline',
className: 'mlm'
}}/>}
</span>
</OverlayTrigger>
</TooltipTrigger>
);

return {children};
Expand Down

0 comments on commit b224729

Please sign in to comment.