[ADF-4933] Adding keydown event on data row to simulate double click when pressing 'enter' key (#5564)

* changing the event on row from keyup to keydown to fix the issue of reopening the file after closing ussing only keyboard (opening and closing the file by enter)

* Reverting the 'onRowKeyDown' to not make a breaking change and added a new method to handle the opening file using 'enter' key

* Added unit test - it should emit double click if keydown "enter key" on row

* Small changes for clean coding
This commit is contained in:
Urse Daniel
2020-03-27 18:33:44 +02:00
committed by GitHub
parent d3ff9eda3f
commit 8f3f5b3879
3 changed files with 38 additions and 7 deletions

View File

@@ -474,11 +474,17 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
this.clickObserver.next(dataRowEvent);
}
onRowKeyUp(row: DataRow, e: KeyboardEvent) {
onRowEnterKeyDown(row: DataRow, keyboardEvent: KeyboardEvent) {
if (keyboardEvent.key === 'Enter') {
this.onKeyboardNavigate(row, keyboardEvent);
}
}
onRowKeyUp(row: DataRow, keyboardEvent: KeyboardEvent) {
const event = new CustomEvent('row-keyup', {
detail: {
row: row,
keyboardEvent: e,
keyboardEvent: keyboardEvent,
sender: this
},
bubbles: true
@@ -487,11 +493,7 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
this.elementRef.nativeElement.dispatchEvent(event);
if (event.defaultPrevented) {
e.preventDefault();
} else {
if (e.key === 'Enter') {
this.onKeyboardNavigate(row, e);
}
keyboardEvent.preventDefault();
}
}