From cc47a5b833fd0ec43fb521dee706b054d1013995 Mon Sep 17 00:00:00 2001 From: Geoff Cameron Date: Fri, 27 Oct 2017 15:20:14 -0400 Subject: [PATCH 1/3] Type in a cell to edit it now --- packages/table/src/cell/cell.tsx | 13 ++++++++++++- packages/table/src/cell/editableCell.tsx | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/packages/table/src/cell/cell.tsx b/packages/table/src/cell/cell.tsx index d13c9af403..dcaf46e1c4 100644 --- a/packages/table/src/cell/cell.tsx +++ b/packages/table/src/cell/cell.tsx @@ -78,6 +78,11 @@ export interface ICellProps extends IIntentProps, IProps { */ onKeyUp?: React.KeyboardEventHandler; + /** + * Callback invoked when a character-key is pressed + */ + onKeyPress?: React.KeyboardEventHandler; + /** * A ref handle to capture the outer div of this cell. Used internally. */ @@ -108,6 +113,7 @@ export class Cell extends React.Component { tabIndex, onKeyDown, onKeyUp, + onKeyPress, style, intent, interactive, @@ -163,7 +169,12 @@ export class Cell extends React.Component { const content =
{modifiedChildren}
; return ( -
+
{content} diff --git a/packages/table/src/cell/editableCell.tsx b/packages/table/src/cell/editableCell.tsx index 6582423a7c..20dfd6e0dc 100644 --- a/packages/table/src/cell/editableCell.tsx +++ b/packages/table/src/cell/editableCell.tsx @@ -120,7 +120,7 @@ export class EditableCell extends React.Component ); @@ -134,7 +134,13 @@ export class EditableCell extends React.Component + { + if (this.state.isEditing) { + return; + } + // setting dirty value to empty string because apparently the text field will pick up the key and write it in there + this.setState({ isEditing: true, dirtyValue: "", savedValue: this.state.savedValue }); + }; + private handleEdit = () => { this.setState({ isEditing: true, dirtyValue: this.state.savedValue }); }; From 7ee50b7ac400731d7bf93a3bfbeb752b5988f234 Mon Sep 17 00:00:00 2001 From: Geoff Cameron Date: Thu, 2 Nov 2017 14:44:12 -0400 Subject: [PATCH 2/3] Disable type-to-edit without focus cell --- packages/table/src/cell/editableCell.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/table/src/cell/editableCell.tsx b/packages/table/src/cell/editableCell.tsx index 20dfd6e0dc..a27ac16f63 100644 --- a/packages/table/src/cell/editableCell.tsx +++ b/packages/table/src/cell/editableCell.tsx @@ -175,7 +175,7 @@ export class EditableCell extends React.Component { - if (this.state.isEditing) { + if (this.state.isEditing || !this.props.isFocused) { return; } // setting dirty value to empty string because apparently the text field will pick up the key and write it in there From b52672fc4a11af6f24c6e6fb4c0206d8a8995197 Mon Sep 17 00:00:00 2001 From: Geoff Cameron Date: Tue, 7 Nov 2017 14:30:36 -0500 Subject: [PATCH 3/3] add period --- packages/table/src/cell/cell.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/table/src/cell/cell.tsx b/packages/table/src/cell/cell.tsx index dcaf46e1c4..f4a41c410b 100644 --- a/packages/table/src/cell/cell.tsx +++ b/packages/table/src/cell/cell.tsx @@ -79,7 +79,7 @@ export interface ICellProps extends IIntentProps, IProps { onKeyUp?: React.KeyboardEventHandler; /** - * Callback invoked when a character-key is pressed + * Callback invoked when a character-key is pressed. */ onKeyPress?: React.KeyboardEventHandler;