Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class TableViewItemComponent extends PureComponent {
this.enablePriorityInput = this.enablePriorityInput.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.handleCancel = this.handleCancel.bind(this);
this.handlePriorityInputKeyDown = this.handlePriorityInputKeyDown.bind(this);
this.handleEdit = this.handleEdit.bind(this);
this.onSelectCheckboxChange = this.onSelectCheckboxChange.bind(this);
this.setPriorityInputRef = this.setPriorityInputRef.bind(this);
Expand Down Expand Up @@ -100,6 +101,22 @@ export default class TableViewItemComponent extends PureComponent {
}));
}

/**
* Handles priority input keyboard events.
* Submits the new priority value on Enter and cancels the update on Escape.
*
* @method handlePriorityInputKeyDown
* @param {Event} event
* @memberof TableViewItemComponent
*/
handlePriorityInputKeyDown(event) {
if (event.key === 'Enter') {
this.handleSubmit(event);
} else if (event.key === 'Escape') {
this.handleCancel(event);
}
}

/**
* Stores priority value
*
Expand Down Expand Up @@ -195,12 +212,14 @@ export default class TableViewItemComponent extends PureComponent {
type: 'number',
defaultValue: this.state.priorityValue,
onChange: this.storePriorityValue,
onKeyDown: this.handlePriorityInputKeyDown,
};
const priorityWrapperAttrs = {};
const innerWrapperAttrs = {};

if (!this.state.priorityInputEnabled) {
delete inputAttrs.defaultValue;
delete inputAttrs.onKeyDown;
inputAttrs.value = this.state.priorityValue;
priorityWrapperAttrs.onClick = this.enablePriorityInput;
innerWrapperAttrs.hidden = true;
Expand Down
Loading