Skip to content

Commit 4c48024

Browse files
JamesPortelliamanmahajan7
authored andcommitted
Cell Tooltip - Focus Issues (#1422)
* change level tooltip gets rendered and level it gets triggered * remove unsed editors and fix imports. * re order inclusion of frozen cells to avoid z-index css. * address comments * Revert "remove unsed editors and fix imports." This reverts commit 3b22f60. * fix issues * fix issues * remove extra space
1 parent 09c7fa4 commit 4c48024

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed

packages/react-data-grid/src/Cell.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class Cell extends React.PureComponent {
174174
let extraClasses = joinClasses({
175175
'row-selected': this.props.isRowSelected,
176176
editing: this.isEditorEnabled(),
177-
'cell-tooltip': this.props.tooltip ? true : false,
177+
'has-tooltip': this.props.tooltip ? true : false,
178178
'rdg-child-cell': this.props.expandableOptions && this.props.expandableOptions.subRowDetails && this.props.expandableOptions.treeDepth > 0,
179179
'last-column': this.props.column.isLastColumn
180180
});
@@ -317,13 +317,20 @@ class Cell extends React.PureComponent {
317317
if (treeDepth > 0 && isExpandCell) {
318318
cellDeleter = <ChildRowDeleteButton treeDepth={treeDepth} cellHeight={this.props.height} siblingIndex={this.props.expandableOptions.subRowDetails.siblingIndex} numberSiblings={this.props.expandableOptions.subRowDetails.numberSiblings} onDeleteSubRow={this.onDeleteSubRow} isDeleteSubRowEnabled={isDeleteSubRowEnabled} />;
319319
}
320+
321+
const tooltip = this.props.tooltip && (<span className="cell-tooltip-text">{this.props.tooltip}</span>);
322+
const classes = joinClasses('react-grid-Cell__value',
323+
{ 'cell-tooltip': this.props.tooltip ? true : false }
324+
);
325+
320326
return (
321-
<div className="react-grid-Cell__value">
327+
<div className={classes}>
322328
{cellDeleter}
323329
<div style={{ marginLeft, position: 'relative', top: '50%', transform: 'translateY(-50%)' }}>
324330
<span>{CellContent}</span>
325331
{this.props.cellControls}
326332
</div>
333+
{tooltip}
327334
</div>
328335
);
329336
};
@@ -347,8 +354,7 @@ class Cell extends React.PureComponent {
347354
isScrolling
348355
});
349356

350-
let events = this.getEvents();
351-
const tooltip = this.props.tooltip ? (<span className="cell-tooltip-text">{this.props.tooltip}</span>) : null;
357+
const events = this.getEvents();
352358

353359
const cellExpander = this.canExpand() && (
354360
<CellExpand expandableOptions={this.props.expandableOptions} onCellExpand={this.onCellExpand} />
@@ -365,7 +371,6 @@ class Cell extends React.PureComponent {
365371
{cellActionButtons}
366372
{cellExpander}
367373
{cellContent}
368-
{tooltip}
369374
</div>
370375
);
371376
}

packages/react-data-grid/src/Row.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Row extends React.Component {
9191
const { colOverscanStartIdx, colOverscanEndIdx, columns } = this.props;
9292
const frozenColumns = columns.filter(c => columnUtils.isFrozen(c));
9393
const nonFrozenColumnsToRender = columns.slice(colOverscanStartIdx, colOverscanEndIdx + 1).filter(c => !columnUtils.isFrozen(c));
94-
return frozenColumns.concat(nonFrozenColumnsToRender)
94+
return nonFrozenColumnsToRender.concat(frozenColumns)
9595
.map(column => this.getCell(column));
9696
};
9797

packages/react-data-grid/src/__tests__/Row.spec.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,6 @@ describe('Row', () => {
137137
const renderedRange = colOverscanEndIdx - colOverscanStartIdx + 1;
138138
expect(cells.length).toBe(renderedRange);
139139
});
140-
141-
it('first rendered cell index should be first frozen cell', () => {
142-
const columns = lockColumns(LAST_LOCKED_CELL_IDX);
143-
const {cells} = setup({...requiredProperties, columns});
144-
const firstFrozenColumn = columns.filter(c => c.frozen === true)[0];
145-
expect(cells.first().props().column).toBe(firstFrozenColumn);
146-
});
147140
});
148141

149142
describe('When not using frozen columns', () => {

themes/react-data-grid-cell.css

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@
3232
box-shadow: 2px 0 5px -2px rgba(136, 136, 136, .3) !important;
3333
}
3434

35+
/* cell which have tooltips need to have a higher z-index on hover so that the tooltip appears above the other cells*/
36+
.react-grid-Cell.has-tooltip:hover {
37+
z-index: 5;
38+
}
39+
40+
.react-grid-Cell.react-grid-Cell--frozen.has-tooltip:hover {
41+
z-index: 15;
42+
}
43+
3544
.react-contextmenu--visible {
3645
z-index: 1000;
3746
}
@@ -90,16 +99,8 @@
9099
padding: 0;
91100
}
92101

93-
.cell-tooltip {
94-
position: relative;
95-
display: inline-block;
96-
}
97-
98-
.cell-tooltip:hover {
99-
z-index: 101;
100-
}
101-
102102
.cell-tooltip .cell-tooltip-text {
103+
white-space: normal;
103104
visibility: hidden;
104105
width: 150px;
105106
background-color: black;
@@ -108,12 +109,11 @@
108109
border-radius: 6px;
109110
padding: 5px 0;
110111
position: absolute;
111-
z-index: 1;
112-
bottom: -150%;
112+
top: 50%;
113+
bottom: initial;
113114
left: 50%;
114-
margin-left: -60px;
115-
/* Fade in tooltip - takes 1 second to go from 0% to 100% opacity */
116-
opacity: 1s;
115+
margin-top: 15px;
116+
margin-left: -75px
117117
}
118118

119119
.cell-tooltip:hover .cell-tooltip-text {

0 commit comments

Comments
 (0)