Skip to content

Commit

Permalink
feat(platform): propagate ctrlKey from the table row mouse/keyboard e…
Browse files Browse the repository at this point in the history
…vent (#12747)

* feat(platform): propagate ctrlKey from the table row mouse/keyboard event

* feat(platform): propagate metaKey as well

* chore(platform): remove duplicate showItemsCount

---------

Co-authored-by: Robert Isaac <[email protected]>
  • Loading branch information
mikerodonnell89 and robertIsaac authored Nov 22, 2024
1 parent 30cce54 commit 9f341c9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ export class TableRowActivateEvent<T> {
/**
* Table row activate event
* @param index Index of the activated row
* @param ctrlKey Whether control/command key was pressed during the mouse/keyboard event
* @param row Row that was activated
*/
constructor(
public index: number,
public ctrlKey: boolean,
public row: T
) {}
}
4 changes: 2 additions & 2 deletions libs/platform/table/table.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
</div>
@if (showGrowingButton) {
<fdp-table-growing-button [showItemsCount]="showItemsCount" [showItemsCount]="true"></fdp-table-growing-button>
<fdp-table-growing-button [showItemsCount]="showItemsCount"></fdp-table-growing-button>
}
</fd-busy-indicator>
<!-- Table Template -->
Expand Down Expand Up @@ -93,7 +93,7 @@
[keyToColumnMap]="_keyToColumnMap"
[tableColumnsLength]="_tableColumnsLength"
(toggleGroupRow)="_toggleGroupRow($event)"
(click)="_emitRowActivate(row)"
(click)="_emitRowActivate(row, $event.ctrlKey || $event.metaKey)"
></tr>
}
@default {
Expand Down
14 changes: 8 additions & 6 deletions libs/platform/table/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1606,8 +1606,10 @@ export class TableComponent<T = any>
}

if (row) {
this._emitRowNavigate(row);
this._emitRowActivate(row);
const e = event as MouseEvent | KeyboardEvent;
const ctrlKey = e.ctrlKey || e.metaKey;
this._emitRowNavigate(row, ctrlKey);
this._emitRowActivate(row, ctrlKey);
}
}

Expand All @@ -1617,13 +1619,13 @@ export class TableComponent<T = any>
}

/** @hidden */
_emitRowActivate(row: TableRow<T>): void {
_emitRowActivate(row: TableRow<T>, ctrlKey: boolean): void {
if (!this.rowsActivable) {
return;
}

const rowIndex = this._tableRows.indexOf(row);
this.rowActivate.emit(new TableRowActivateEvent<T>(rowIndex, row.value));
this.rowActivate.emit(new TableRowActivateEvent<T>(rowIndex, ctrlKey, row.value));
}

/**
Expand All @@ -1644,7 +1646,7 @@ export class TableComponent<T = any>
}

/** @hidden */
_emitRowNavigate(row: TableRow<T>): void {
_emitRowNavigate(row: TableRow<T>, ctrlKey: boolean): void {
if (!row.navigatable) {
return;
}
Expand All @@ -1654,7 +1656,7 @@ export class TableComponent<T = any>
this._navigatedRowIndex = rowIndex;
}

this.rowNavigate.emit(new TableRowActivateEvent<T>(rowIndex, row.value));
this.rowNavigate.emit(new TableRowActivateEvent<T>(rowIndex, ctrlKey, row.value));
}

/** Fetch data source data. */
Expand Down

0 comments on commit 9f341c9

Please sign in to comment.