Skip to content

Commit

Permalink
Merge pull request #3158 from kuhelbeher/feature/inputNumber_keyboard
Browse files Browse the repository at this point in the history
Add keydown event to handle up and down arrows keypress events
  • Loading branch information
artf authored Nov 26, 2020
2 parents 089a50a + 9b25e7e commit d47c495
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/domain_abstract/ui/InputNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export default Input.extend({
'change select': 'handleUnitChange',
'click [data-arrow-up]': 'upArrowClick',
'click [data-arrow-down]': 'downArrowClick',
'mousedown [data-arrows]': 'downIncrement'
'mousedown [data-arrows]': 'downIncrement',
keydown: 'handleKeyDown'
},

template() {
Expand Down Expand Up @@ -81,6 +82,21 @@ export default Input.extend({
this.elementUpdated();
},

/**
* Handled when user uses keyboard
*/
handleKeyDown(e) {
if (e.key === 'ArrowUp') {
e.preventDefault();
this.upArrowClick();
}

if (e.key === 'ArrowDown') {
e.preventDefault();
this.downArrowClick();
}
},

/**
* Fired when the element of the property is updated
*/
Expand Down

0 comments on commit d47c495

Please sign in to comment.