Skip to content

Commit

Permalink
fix(platform): fixed table row excessive focus and toggle handling wi…
Browse files Browse the repository at this point in the history
…th space (#11000) (#11015)
  • Loading branch information
g-cheishvili authored Nov 27, 2023
1 parent 7f49f35 commit f420e48
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
last as isLast;
trackBy: _columnTrackBy
"
#tableCellElement
[fdpTableCellResizable]="
colIdx
| columnResizableSide
Expand Down Expand Up @@ -139,6 +140,7 @@
(keydown.enter)="_isTreeRowFirstCell(colIdx, row, $event) && _toggleGroupRow()"
(keydown.arrowLeft)="_tableRowService.scrollToOverlappedCell()"
(keydown.arrowRight)="_tableRowService.scrollToOverlappedCell()"
(keydown.space)="_handleCellSpaceKey(colIdx, tableCellElement, $event)"
>
<div [class.fd-table__text]="column.applyText" [class.fd-table__text--no-wrap]="column.noWrap">
<span
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/member-ordering */
import { DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, UP_ARROW } from '@angular/cdk/keycodes';
import { DOWN_ARROW, UP_ARROW } from '@angular/cdk/keycodes';
import {
AfterViewInit,
ChangeDetectionStrategy,
Expand All @@ -8,7 +8,6 @@ import {
ElementRef,
EventEmitter,
HostBinding,
HostListener,
Input,
NgZone,
OnChanges,
Expand Down Expand Up @@ -219,18 +218,6 @@ export class TableRowComponent<T> extends TableRowDirective implements OnInit, A
});
}

/** @hidden */
@HostListener('keydown.arrowLeft', ['$event'])
@HostListener('keydown.arrowRight', ['$event'])
private _onArrowKeydown($event: KeyboardEvent): void {
if ($event.target === this._elmRef.nativeElement && this.isTreeRow) {
const shouldBeOpen = KeyUtil.isKeyCode($event, this._rtl ? LEFT_ARROW : RIGHT_ARROW);
if (shouldBeOpen !== this.row.expanded) {
this._toggleGroupRow();
}
}
}

/** @hidden */
ngOnInit(): void {
super.ngOnInit();
Expand Down Expand Up @@ -269,6 +256,14 @@ export class TableRowComponent<T> extends TableRowDirective implements OnInit, A
this._tableRowService.removeEditableCells(this.row);
}

/** @hidden */
protected _handleCellSpaceKey(colIdx: number, tableCellElement: HTMLTableCellElement, $event: Event): void {
if ($event.target === tableCellElement && isTreeRowFirstCell(colIdx, this.row, $event)) {
$event.preventDefault();
this._toggleGroupRow();
}
}

/** @hidden */
private _listenToRowExpansion(): void {
this._refreshChildRows$.next();
Expand Down
4 changes: 2 additions & 2 deletions libs/platform/src/lib/table/table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
[fdkDndItem]="row"
[applyDragItemClass]="isDraggable"
[class]="row | rowClasses : rowsClass"
[tabindex]="row.isTree || rowsActivable || !!row.navigatable ? 0 : -1"
[focusable]="row.isTree || rowsActivable || !!row.navigatable"
[tabindex]="rowsActivable || !!row.navigatable ? 0 : -1"
[focusable]="rowsActivable || !!row.navigatable"
[hoverable]="rowsActivable || isSelectionColumnShown() || !!row.navigatable"
[activable]="rowsActivable || !!row.navigatable"
[active]="rowIndex === _navigatedRowIndex"
Expand Down

0 comments on commit f420e48

Please sign in to comment.