Skip to content

Commit

Permalink
#887 and#878 (#888)
Browse files Browse the repository at this point in the history
* Fixes for issues #878 and #887

* Changing hint to label

* Making the columnHeaderTooltip customizable for any column prop

* Resolving comments

* Add option to readme

* Doc update
  • Loading branch information
Avd6977 authored and gabrielliwerant committed Sep 12, 2019
1 parent 6d44805 commit fdd7ee7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ const options = {
body: {
noMatch: "Sorry, no matching records found",
toolTip: "Sort",
columnHeaderTooltip: column => `Sort for ${column.label}`
},
pagination: {
next: "Next Page",
Expand Down
2 changes: 1 addition & 1 deletion src/MUIDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Paper from '@material-ui/core/Paper';
import { withStyles } from '@material-ui/core/styles';
import MuiTable from '@material-ui/core/Table';
import classnames from 'classnames';
import assignwith from 'lodash.assignwith';
import cloneDeep from 'lodash.clonedeep';
import find from 'lodash.find';
import isUndefined from 'lodash.isundefined';
import merge from 'lodash.merge';
import assignwith from 'lodash.assignwith';
import PropTypes from 'prop-types';
import React from 'react';
import TableBody from './components/TableBody';
Expand Down
11 changes: 6 additions & 5 deletions src/components/TableHead.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { withStyles } from '@material-ui/core/styles';
import MuiTableHead from '@material-ui/core/TableHead';
import classNames from 'classnames';
import React from 'react';
import { findDOMNode } from 'react-dom';
import classNames from 'classnames';
import MuiTableHead from '@material-ui/core/TableHead';
import TableHeadRow from './TableHeadRow';
import TableHeadCell from './TableHeadCell';
import TableHeadRow from './TableHeadRow';
import TableSelectCell from './TableSelectCell';
import { withStyles } from '@material-ui/core/styles';

const defaultHeadStyles = theme => ({
main: {},
Expand Down Expand Up @@ -68,7 +68,8 @@ class TableHead extends React.Component {
toggleSort={this.handleToggleColumn}
hint={column.hint}
print={column.print}
options={options}>
options={options}
column={column}>
{column.label}
</TableHeadCell>
)),
Expand Down
18 changes: 12 additions & 6 deletions src/components/TableHeadCell.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { withStyles } from '@material-ui/core/styles';
import TableCell from '@material-ui/core/TableCell';
import TableSortLabel from '@material-ui/core/TableSortLabel';
import Tooltip from '@material-ui/core/Tooltip';
import { withStyles } from '@material-ui/core/styles';
import HelpIcon from '@material-ui/icons/Help';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';

const defaultHeadCellStyles = theme => ({
root: {},
Expand Down Expand Up @@ -68,6 +68,8 @@ class TableHeadCell extends React.Component {
hint: PropTypes.string,
/** Column displayed in print */
print: PropTypes.bool.isRequired,
/** Optional to be used with `textLabels.body.columnHeaderTooltip` */
column: PropTypes.object,
};

state = {
Expand All @@ -89,7 +91,7 @@ class TableHeadCell extends React.Component {

render() {
const { isSortTooltipOpen, isHintTooltipOpen } = this.state;
const { children, classes, options, sortDirection, sort, hint, print } = this.props;
const { children, classes, options, sortDirection, sort, hint, print, column } = this.props;
const sortActive = sortDirection !== 'none' && sortDirection !== undefined ? true : false;
const ariaSortDirection = sortDirection === 'none' ? false : sortDirection;

Expand All @@ -110,7 +112,11 @@ class TableHeadCell extends React.Component {
<TableCell className={cellClass} scope={'col'} sortDirection={ariaSortDirection}>
{options.sort && sort ? (
<Tooltip
title={options.textLabels.body.toolTip}
title={
options.textLabels.body.columnHeaderTooltip
? options.textLabels.body.columnHeaderTooltip(column)
: options.textLabels.body.toolTip
}
placement={'bottom-start'}
classes={{
tooltip: classes.tooltip,
Expand Down

0 comments on commit fdd7ee7

Please sign in to comment.