Skip to content

Commit 2bcfcc2

Browse files
committed
fix: do not allow focusing of cell when not in cell selection mode
1 parent b16e6a3 commit 2bcfcc2

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

projects/ngx-datatable/src/lib/components/body/body-row.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
import { columnGroupWidths, columnsByPin, columnsByPinArr } from '../../utils/column';
2020
import { Keys } from '../../utils/keys';
2121
import { BehaviorSubject } from 'rxjs';
22-
import { ActivateEvent, RowOrGroup, TreeStatus } from '../../types/public.types';
22+
import { ActivateEvent, RowOrGroup, SelectionType, TreeStatus } from '../../types/public.types';
2323
import { AsyncPipe } from '@angular/common';
2424
import { TableColumn } from '../../types/table-column.type';
2525
import { ColumnGroupWidth, PinnedColumns } from '../../types/internal.types';
@@ -38,7 +38,7 @@ import { DataTableBodyCellComponent } from './body-cell.component';
3838
@for (column of colGroup.columns; track column.$$id; let ii = $index) {
3939
<datatable-body-cell
4040
role="cell"
41-
tabindex="-1"
41+
[attr.tabindex]="selectionType == SelectionType.cell ? '-1' : null"
4242
[row]="row"
4343
[group]="group"
4444
[expanded]="expanded"
@@ -62,6 +62,8 @@ import { DataTableBodyCellComponent } from './body-cell.component';
6262
imports: [DataTableBodyCellComponent, AsyncPipe]
6363
})
6464
export class DataTableBodyRowComponent<TRow = any> implements DoCheck, OnChanges {
65+
SelectionType = SelectionType;
66+
6567
private cd = inject(ChangeDetectorRef);
6668

6769
@Input() set columns(val: TableColumn[]) {
@@ -92,6 +94,7 @@ export class DataTableBodyRowComponent<TRow = any> implements DoCheck, OnChanges
9294
@Input() row: TRow;
9395
@Input() group: TRow[];
9496
@Input() isSelected: boolean;
97+
@Input() selectionType: SelectionType;
9598
@Input() rowIndex: number;
9699
@Input() displayCheck: (row: TRow, column: TableColumn, value?: any) => boolean;
97100
@Input() treeStatus?: TreeStatus = 'collapsed';

projects/ngx-datatable/src/lib/components/body/body.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ import { ProgressBarComponent } from './progress-bar.component';
8585
<datatable-summary-row
8686
[rowHeight]="summaryHeight"
8787
[offsetX]="offsetX"
88+
[selectionType]="selectionType"
8889
[innerWidth]="innerWidth"
8990
[rows]="rows"
9091
[columns]="columns"
@@ -131,6 +132,7 @@ import { ProgressBarComponent } from './progress-bar.component';
131132
[isSelected]="selector.getRowSelected(group)"
132133
[innerWidth]="innerWidth"
133134
[offsetX]="offsetX"
135+
[selectionType]="selectionType"
134136
[columns]="columns"
135137
[rowHeight]="getRowHeight(group)"
136138
[row]="group"
@@ -165,6 +167,7 @@ import { ProgressBarComponent } from './progress-bar.component';
165167
[isSelected]="selector.getRowSelected(group)"
166168
[innerWidth]="innerWidth"
167169
[offsetX]="offsetX"
170+
[selectionType]="selectionType"
168171
[columns]="columns"
169172
[rowHeight]="getRowHeight(group)"
170173
[row]="group"
@@ -200,6 +203,7 @@ import { ProgressBarComponent } from './progress-bar.component';
200203
[isSelected]="selector.getRowSelected(row)"
201204
[innerWidth]="innerWidth"
202205
[offsetX]="offsetX"
206+
[selectionType]="selectionType"
203207
[columns]="columns"
204208
[rowHeight]="getRowHeight(row)"
205209
[row]="row"
@@ -229,6 +233,7 @@ import { ProgressBarComponent } from './progress-bar.component';
229233
[ngStyle]="bottomSummaryRowsStyles()"
230234
[rowHeight]="summaryHeight"
231235
[offsetX]="offsetX"
236+
[selectionType]="selectionType"
232237
[innerWidth]="innerWidth"
233238
[rows]="rows"
234239
[columns]="columns"

projects/ngx-datatable/src/lib/components/body/summary/summary-row.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, Input, OnChanges, PipeTransform, TemplateRef } from '@angular/core';
22
import { TableColumn, TableColumnProp } from '../../../types/table-column.type';
33
import { DataTableBodyRowComponent } from '../body-row.component';
4+
import { SelectionType } from '../../../types/public.types';
45

56
export interface ISummaryColumn {
67
summaryFunc?: (cells: any[]) => any;
@@ -35,6 +36,7 @@ function noopSumFunc(cells: any[]): void {
3536
tabindex="-1"
3637
[innerWidth]="innerWidth"
3738
[offsetX]="offsetX"
39+
[selectionType]="selectionType"
3840
[columns]="_internalColumns"
3941
[rowHeight]="rowHeight"
4042
[row]="summaryRow"
@@ -55,6 +57,7 @@ export class DataTableSummaryRowComponent implements OnChanges {
5557

5658
@Input() rowHeight: number;
5759
@Input() offsetX: number;
60+
@Input() selectionType: SelectionType;
5861
@Input() innerWidth: number;
5962

6063
_internalColumns: ISummaryColumn[];

0 commit comments

Comments
 (0)