Skip to content

Commit

Permalink
Updated TableRow to support single column
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Feb 13, 2017
1 parent 9ebb8bf commit 6414843
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/js/DataTables/TableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ export default class TableRow extends Component {
className: PropTypes.string,

/**
* A list of `TableColumn` to display in the table.
* A single or list of `TableColumn` to display in the table.
*
* > There should be at least 3 columns in a Data table (non plain)
* > The specs "require" at least 3 columns for a non-plain data table, but that isn't
* strictly enforced here.
*/
children: PropTypes.arrayOf(PropTypes.element).isRequired,
children: PropTypes.oneOfType([
PropTypes.element,
PropTypes.arrayOf(PropTypes.element),
]).isRequired,

/**
* An optional onClick function to call when a row is clicked.
Expand Down Expand Up @@ -197,7 +201,7 @@ export default class TableRow extends Component {
}

const length = children.length;
const columns = Children.map(children, (col, i) => cloneElement(col, {
const columns = Children.map(Children.toArray(children), (col, i) => cloneElement(col, {
header: getField(col.props, this.context, 'header'),
className: cn({
'md-table-column--grow': getField(col.props, this.context, 'header') && biggest && biggest.index === i,
Expand Down

0 comments on commit 6414843

Please sign in to comment.