Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not allow focusing of cell when not in cell selection mode #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -19,7 +19,7 @@ import {
import { columnGroupWidths, columnsByPin, columnsByPinArr } from '../../utils/column';
import { Keys } from '../../utils/keys';
import { BehaviorSubject } from 'rxjs';
import { ActivateEvent, RowOrGroup, TreeStatus } from '../../types/public.types';
import { ActivateEvent, RowOrGroup, SelectionType, TreeStatus } from '../../types/public.types';
import { AsyncPipe } from '@angular/common';
import { TableColumn } from '../../types/table-column.type';
import { ColumnGroupWidth, PinnedColumns } from '../../types/internal.types';
Expand All @@ -38,7 +38,7 @@ import { DataTableBodyCellComponent } from './body-cell.component';
@for (column of colGroup.columns; track column.$$id; let ii = $index) {
<datatable-body-cell
role="cell"
tabindex="-1"
[attr.tabindex]="selectionType === SelectionType.cell ? '-1' : null"
[row]="row"
[group]="group"
[expanded]="expanded"
Expand All @@ -62,6 +62,8 @@ import { DataTableBodyCellComponent } from './body-cell.component';
imports: [DataTableBodyCellComponent, AsyncPipe]
})
export class DataTableBodyRowComponent<TRow = any> implements DoCheck, OnChanges {
SelectionType = SelectionType;

private cd = inject(ChangeDetectorRef);

@Input() set columns(val: TableColumn[]) {
Expand Down Expand Up @@ -92,6 +94,7 @@ export class DataTableBodyRowComponent<TRow = any> implements DoCheck, OnChanges
@Input() row: TRow;
@Input() group: TRow[];
@Input() isSelected: boolean;
@Input() selectionType: SelectionType;
@Input() rowIndex: number;
@Input() displayCheck: (row: TRow, column: TableColumn, value?: any) => boolean;
@Input() treeStatus?: TreeStatus = 'collapsed';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import { ProgressBarComponent } from './progress-bar.component';
<datatable-summary-row
[rowHeight]="summaryHeight"
[offsetX]="offsetX"
[selectionType]="selectionType"
[innerWidth]="innerWidth"
[rows]="rows"
[columns]="columns"
Expand Down Expand Up @@ -131,6 +132,7 @@ import { ProgressBarComponent } from './progress-bar.component';
[isSelected]="selector.getRowSelected(group)"
[innerWidth]="innerWidth"
[offsetX]="offsetX"
[selectionType]="selectionType"
[columns]="columns"
[rowHeight]="getRowHeight(group)"
[row]="group"
Expand Down Expand Up @@ -165,6 +167,7 @@ import { ProgressBarComponent } from './progress-bar.component';
[isSelected]="selector.getRowSelected(group)"
[innerWidth]="innerWidth"
[offsetX]="offsetX"
[selectionType]="selectionType"
[columns]="columns"
[rowHeight]="getRowHeight(group)"
[row]="group"
Expand Down Expand Up @@ -200,6 +203,7 @@ import { ProgressBarComponent } from './progress-bar.component';
[isSelected]="selector.getRowSelected(row)"
[innerWidth]="innerWidth"
[offsetX]="offsetX"
[selectionType]="selectionType"
[columns]="columns"
[rowHeight]="getRowHeight(row)"
[row]="row"
Expand Down Expand Up @@ -229,6 +233,7 @@ import { ProgressBarComponent } from './progress-bar.component';
[ngStyle]="bottomSummaryRowsStyles()"
[rowHeight]="summaryHeight"
[offsetX]="offsetX"
[selectionType]="selectionType"
[innerWidth]="innerWidth"
[rows]="rows"
[columns]="columns"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, Input, OnChanges, PipeTransform, TemplateRef } from '@angular/core';
import { TableColumn, TableColumnProp } from '../../../types/table-column.type';
import { DataTableBodyRowComponent } from '../body-row.component';
import { SelectionType } from '../../../types/public.types';

export interface ISummaryColumn {
summaryFunc?: (cells: any[]) => any;
Expand Down Expand Up @@ -35,6 +36,7 @@ function noopSumFunc(cells: any[]): void {
tabindex="-1"
[innerWidth]="innerWidth"
[offsetX]="offsetX"
[selectionType]="selectionType"
[columns]="_internalColumns"
[rowHeight]="rowHeight"
[row]="summaryRow"
Expand All @@ -55,6 +57,7 @@ export class DataTableSummaryRowComponent implements OnChanges {

@Input() rowHeight: number;
@Input() offsetX: number;
@Input() selectionType: SelectionType;
@Input() innerWidth: number;

_internalColumns: ISummaryColumn[];
Expand Down
Loading