Skip to content

Commit

Permalink
fix #994
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Jan 31, 2017
1 parent 1aaf605 commit d149941
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
9 changes: 8 additions & 1 deletion src/TableEditColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ class TableEditColumn extends Component {
this.clearTimeout();
}

handleClick = e => {
if (e.target.tagName !== 'TD') {
e.stopPropagation();
}
}

render() {
const { editable, format, customEditor } = this.props;
const { shakeEditor, className } = this.state;
Expand Down Expand Up @@ -146,7 +152,8 @@ class TableEditColumn extends Component {
return (
<td ref='td'
style={ { position: 'relative' } }
className={ className }>
className={ className }
onClick={ this.handleClick }>
{ cellEditor }
<Notifier ref='notifier'/>
</td>
Expand Down
42 changes: 20 additions & 22 deletions src/TableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,29 @@ class TableRow extends Component {
rowClick = e => {
const rowIndex = this.props.index + 1;
if (this.props.onRowClick) this.props.onRowClick(rowIndex);
if (e.target.tagName === 'TD') {
const cellIndex = e.target.cellIndex;
const { selectRow, unselectableRow, isSelected, onSelectRow, onExpandRow } = this.props;
if (selectRow) {
if (selectRow.clickToSelect && !unselectableRow) {
onSelectRow(rowIndex, !isSelected, e);
} else if (selectRow.clickToSelectAndEditCell && !unselectableRow) {
this.clickNum++;
/** if clickToSelectAndEditCell is enabled,
* there should be a delay to prevent a selection changed when
* user dblick to edit cell on same row but different cell
**/
setTimeout(() => {
if (this.clickNum === 1) {
onSelectRow(rowIndex, !isSelected, e);
onExpandRow(rowIndex, cellIndex);
}
this.clickNum = 0;
}, 200);
} else {
this.expandRow(rowIndex, cellIndex);
}
const cellIndex = e.target.cellIndex;
const { selectRow, unselectableRow, isSelected, onSelectRow, onExpandRow } = this.props;
if (selectRow) {
if (selectRow.clickToSelect && !unselectableRow) {
onSelectRow(rowIndex, !isSelected, e);
} else if (selectRow.clickToSelectAndEditCell && !unselectableRow) {
this.clickNum++;
/** if clickToSelectAndEditCell is enabled,
* there should be a delay to prevent a selection changed when
* user dblick to edit cell on same row but different cell
**/
setTimeout(() => {
if (this.clickNum === 1) {
onSelectRow(rowIndex, !isSelected, e);
onExpandRow(rowIndex, cellIndex);
}
this.clickNum = 0;
}, 200);
} else {
this.expandRow(rowIndex, cellIndex);
}
} else {
this.expandRow(rowIndex, cellIndex);
}
}

Expand Down

0 comments on commit d149941

Please sign in to comment.