Skip to content
Merged
Show file tree
Hide file tree
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 @@ -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 }}
</mat-checkbox>
</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading