From 32f244d9344a8f5949f4b27b79b6c33d4a2961d7 Mon Sep 17 00:00:00 2001 From: AleksanderSklorz <115619721+AleksanderSklorz@users.noreply.github.com> Date: Mon, 29 May 2023 12:49:25 +0200 Subject: [PATCH] [ADF-5517] Reverted extra bug fixes changes (#8605) * ADF-5517 Reverted extra bug fixes changes * ADF-5517 Reverted extra bug fixes changes --- .../datatable/datatable.component.html | 3 +-- .../datatable/datatable.component.spec.ts | 2 +- .../datatable/datatable.component.ts | 18 +++++------------- 3 files changed, 7 insertions(+), 16 deletions(-) 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 5fdbce2a4b..83066fc6b6 100644 --- a/lib/core/src/lib/datatable/components/datatable/datatable.component.html +++ b/lib/core/src/lib/datatable/components/datatable/datatable.component.html @@ -166,7 +166,6 @@ (select)="onEnterKeyPressed(row, $event)" (keyup)="onRowKeyUp(row, $event)" (keydown)="onRowEnterKeyDown(row, $event)" - (click)="onRowClick(row, $event)" [adf-upload]="rowAllowsDrop(row)" [adf-upload-data]="row" [ngStyle]="rowStyle" @@ -210,7 +209,7 @@ [attr.data-automation-id]="getAutomationValue(row)" [attr.aria-selected]="row.isSelected ? true : false" [attr.aria-label]="col.title ? (col.title | translate) : null" - (click)="storeActiveRow(row)" + (click)="onRowClick(row, $event)" (keydown.enter)="onEnterKeyPressed(row, $any($event))" [adf-context-menu]="getContextMenuActions(row, col)" [adf-context-menu-enabled]="contextMenu" 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 46c8f9a2e3..2aa39236e1 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 @@ -1352,7 +1352,7 @@ describe('DataTable', () => { dataTable.resetSelection(); const rowClickPromise = dataTable.rowClick.pipe(take(1)).toPromise(); - const rowElement = fixture.debugElement.query(By.css(`[data-automation-id="datatable-row-0"]`)).nativeElement as HTMLElement; + const rowElement = fixture.debugElement.query(By.css(`[data-automation-id="datatable-row-0"] > div`)).nativeElement as HTMLElement; rowElement.dispatchEvent(new MouseEvent('click')); fixture.detectChanges(); await rowClickPromise; diff --git a/lib/core/src/lib/datatable/components/datatable/datatable.component.ts b/lib/core/src/lib/datatable/components/datatable/datatable.component.ts index 9989b7495e..5406049d45 100644 --- a/lib/core/src/lib/datatable/components/datatable/datatable.component.ts +++ b/lib/core/src/lib/datatable/components/datatable/datatable.component.ts @@ -501,24 +501,16 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges, } onRowClick(row: DataRow, mouseEvent: MouseEvent) { - if (!mouseEvent.composedPath().some( - (element: HTMLElement) => element.id?.startsWith('action_menu_right_') || element.classList?.contains('adf-checkbox-sr-only')) - ) { - if (mouseEvent) { - mouseEvent.preventDefault(); - } - - if (row) { - const dataRowEvent = new DataRowEvent(row, mouseEvent, this); - this.clickObserver.next(dataRowEvent); - } + if (mouseEvent) { + mouseEvent.preventDefault(); } - } - storeActiveRow(row: DataRow) { if (row) { const rowIndex = this.data.getRows().indexOf(row) + (this.isHeaderListVisible() ? 1 : 0); this.keyManager.setActiveItem(rowIndex); + + const dataRowEvent = new DataRowEvent(row, mouseEvent, this); + this.clickObserver.next(dataRowEvent); } }