Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! Fix the ctrl shift and meta key issue
Browse files Browse the repository at this point in the history
shadowbas authored and bas080 committed Dec 9, 2024
1 parent 33d0bdc commit c5b1b33
Showing 2 changed files with 10 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/app/accessible-table/accessible-table.component.html
Original file line number Diff line number Diff line change
@@ -53,7 +53,6 @@
>
<mat-checkbox
tabindex="-1"
(change)="onCheckboxChange($event, row, $index)"
(click)="onCheckboxClick($event, row, $index)"
[checked]="selectedRows[$index]"
></mat-checkbox>
21 changes: 10 additions & 11 deletions src/app/accessible-table/accessible-table.component.ts
Original file line number Diff line number Diff line change
@@ -59,13 +59,14 @@ export class AccessibleTableComponent implements AfterViewChecked, OnChanges {

ngOnChanges(changes: SimpleChanges): void {
if (changes.rows) {
this.selectedRowsChange.emit([])
this.viewport.scrollToIndex(0, 'smooth')
if (this.selectedRows.length) this.selectedRowsChange.emit([])

this.viewport?.scrollToIndex(0, 'smooth')
}

if (changes.selectedRow) {
const index = this.rows.indexOf(this.selectedRow)
this.viewport.scrollToIndex(index, 'smooth');
this.viewport?.scrollToIndex(index, 'smooth');
}

}
@@ -87,13 +88,8 @@ export class AccessibleTableComponent implements AfterViewChecked, OnChanges {
}
}

// Change gets called before click.
onCheckboxChange(event, row, index) {
this.onRowClick(event, row, index)
}

onCheckboxClick(event, row, index) {
// We don not want to trigger the row click when clicking on checkbox.
this.onRowClick(event, row, index, true)
event.stopPropagation()
}

@@ -123,7 +119,7 @@ export class AccessibleTableComponent implements AfterViewChecked, OnChanges {
this.lastCheckedRow = this.rows[to]
}

onRowClick(event, row, index) {
onRowClick(event, row, index, checkbox = false) {
const shiftKey = event.getModifierState("Shift")

if (shiftKey) {
@@ -137,7 +133,10 @@ export class AccessibleTableComponent implements AfterViewChecked, OnChanges {
return this.oneSelect(index, !this.selectedRows[index])
}

this.selectedRowChange.emit(row)
if (!checkbox) {
this.selectedRowChange.emit(row)
}

this.lastCheckedRow = row
}

0 comments on commit c5b1b33

Please sign in to comment.