-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Table/EditableCell] Type in a cell to edit it now #1760
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,7 +120,7 @@ export class EditableCell extends React.Component<IEditableCellProps, IEditableC | |
onConfirm={this.handleConfirm} | ||
onEdit={this.handleEdit} | ||
placeholder="" | ||
selectAllOnFocus={true} | ||
selectAllOnFocus={false} | ||
value={dirtyValue} | ||
/> | ||
); | ||
|
@@ -134,7 +134,13 @@ export class EditableCell extends React.Component<IEditableCellProps, IEditableC | |
} | ||
|
||
return ( | ||
<Cell {...spreadableProps} truncated={false} interactive={interactive} cellRef={this.refHandlers.cell}> | ||
<Cell | ||
{...spreadableProps} | ||
truncated={false} | ||
interactive={interactive} | ||
cellRef={this.refHandlers.cell} | ||
onKeyPress={this.handleKeyPress} | ||
> | ||
<Draggable | ||
onActivate={this.handleCellActivate} | ||
onDoubleClick={this.handleCellDoubleClick} | ||
|
@@ -168,6 +174,14 @@ export class EditableCell extends React.Component<IEditableCellProps, IEditableC | |
} | ||
} | ||
|
||
private handleKeyPress = () => { | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is 123 characters long. Curious why Also, can you elaborate a little more on this case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why it wasn't caught. Basically, apparently, you don't need to insert the character yourself. When switched over to an empty text input (or non-empty one, technically), the bubbling up to the top of the browser will apparently get it to write a character. This is... incredibly weird, but, clearly what is happening, and I'm much happier to let chrome type the character than hope that we got the right one out of the keyboard event. |
||
this.setState({ isEditing: true, dirtyValue: "", savedValue: this.state.savedValue }); | ||
}; | ||
|
||
private handleEdit = () => { | ||
this.setState({ isEditing: true, dirtyValue: this.state.savedValue }); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need trailing period for consistency.