diff --git a/src/bundle/ui-dev/src/modules/sub-items/components/table-view/table.view.item.component.js b/src/bundle/ui-dev/src/modules/sub-items/components/table-view/table.view.item.component.js index a65828759..b07e5144e 100644 --- a/src/bundle/ui-dev/src/modules/sub-items/components/table-view/table.view.item.component.js +++ b/src/bundle/ui-dev/src/modules/sub-items/components/table-view/table.view.item.component.js @@ -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); @@ -100,6 +101,24 @@ 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); + this._refPriorityInput.blur(); + } else if (event.key === 'Escape') { + this.handleCancel(event); + this._refPriorityInput.blur(); + } + } + /** * Stores priority value * @@ -195,12 +214,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;