diff --git a/lib/core/src/lib/datatable/components/datatable/datatable.component.html b/lib/core/src/lib/datatable/components/datatable/datatable.component.html index 9e714f2154..ffbfefe9c0 100644 --- a/lib/core/src/lib/datatable/components/datatable/datatable.component.html +++ b/lib/core/src/lib/datatable/components/datatable/datatable.component.html @@ -253,7 +253,9 @@ [aria-label]="'ADF-DATATABLE.ACCESSIBILITY.SELECT_FILE' | translate" data-adf-datatable-row-checkbox (change)="onCheckboxChange(row, $event)" - class="adf-checkbox-sr-only"> + (keydown.enter)="$event.stopPropagation()" + class="adf-checkbox-sr-only" + > {{ 'ADF-DATATABLE.ACCESSIBILITY.SELECT_FILE' | translate }} diff --git a/lib/core/src/lib/datatable/components/datatable/datatable.component.spec.ts b/lib/core/src/lib/datatable/components/datatable/datatable.component.spec.ts index 37e3bc0b0e..e73a6e959a 100644 --- a/lib/core/src/lib/datatable/components/datatable/datatable.component.spec.ts +++ b/lib/core/src/lib/datatable/components/datatable/datatable.component.spec.ts @@ -1395,6 +1395,33 @@ describe('DataTable', () => { expect(rows[1].isSelected).toBeTrue(); }); + it('should call stopPropagation on checkbox keydown enter event', () => { + const petRows = [{ pet: 'dog' }, { pet: 'cat' }]; + dataTable.multiselect = true; + dataTable.data = new ObjectDataTableAdapter(petRows, [new ObjectDataColumn({ key: 'pet' })]); + dataTable.ngOnChanges({ rows: new SimpleChange(null, petRows, false) }); + fixture.detectChanges(); + + const checkboxElement = testingUtils.getByCSS('[data-adf-datatable-row-checkbox]').nativeElement as HTMLElement; + + const enterEvent = new KeyboardEvent('keydown', { + key: 'Enter', + code: 'Enter', + bubbles: true, + cancelable: true + }); + + const stopPropagationSpy = jasmine.createSpy('stopPropagationSpy'); + + Object.assign(enterEvent, { + stopPropagation: stopPropagationSpy + }); + + checkboxElement.dispatchEvent(enterEvent); + + expect(stopPropagationSpy).toHaveBeenCalled(); + }); + it('should be able to display column of type boolean', () => { dataTable.data = new ObjectDataTableAdapter(mockCarsData, mockCarsSchemaDefinition);