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

[AAE-5362] Add option to make actions button visible only on hover #7117

Merged
merged 3 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions docs/core/components/datatable.component.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ Learm more about styling your datatable: [Customizing the component's styles](#c
| ---- | ---- | ------------- | ----------- |
| actions | `boolean` | false | Toggles the data actions column. |
| actionsPosition | `string` | "right" | Position of the actions dropdown menu. Can be "left" or "right". |
| actionsVisibleOnHover | `boolean` | false | If set to true, the actions button will only be visible on row hover. |
| allowFiltering | `boolean` | false | Flag that indicate if the datatable allow the use facet [widget](../../../lib/testing/src/lib/core/pages/form/widgets/widget.ts) search for filtering. |
| columns | `any[]` | \[] | The columns that the datatable will show. |
| contextMenu | `boolean` | false | Toggles custom context menu for the component. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
[attr.data-automation-id]="'datatable-row-' + idx">
<!-- Actions (left) -->
<div *ngIf="actions && actionsPosition === 'left'" role="gridcell" class="adf-datatable-cell">
<button mat-icon-button [matMenuTriggerFor]="menu"
<button mat-icon-button [matMenuTriggerFor]="menu" #matMenuTrigger="matMenuTrigger"
[ngClass]="{'adf-datatable-hide-actions-without-hover': actionsVisibleOnHover && !matMenuTrigger.menuOpen}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it can be extracted to a class method, as it seems to be duplicated in the template

[title]="'ADF-DATATABLE.CONTENT-ACTIONS.TOOLTIP' | translate"
[attr.id]="'action_menu_left_' + idx"
[attr.data-automation-id]="'action_menu_' + idx">
Expand Down Expand Up @@ -209,7 +210,8 @@
<div *ngIf="actions && actionsPosition === 'right'"
role="gridcell"
class="adf-datatable-cell adf-datatable__actions-cell adf-datatable-center-actions-column-ie">
<button mat-icon-button [matMenuTriggerFor]="menu"
<button mat-icon-button [matMenuTriggerFor]="menu" #matMenuTrigger="matMenuTrigger"
[ngClass]="{'adf-datatable-hide-actions-without-hover': actionsVisibleOnHover && !matMenuTrigger.menuOpen}"
[attr.aria-label]="'ADF-DATATABLE.ACCESSIBILITY.ROW_OPTION_BUTTON' | translate"
[title]="'ADF-DATATABLE.CONTENT-ACTIONS.TOOLTIP' | translate"
[attr.id]="'action_menu_right_' + idx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@
top: 4px;
}

.adf-datatable-row:not(:hover) .adf-datatable-hide-actions-without-hover {
display: none;
}

.adf-image-table-cell {
margin: 8px;
padding: 4px;
Expand Down Expand Up @@ -439,6 +443,10 @@
display: flex;
}

.adf-datatable-row:not(:hover) .adf-datatable-hide-actions-without-hover {
display: none;
}

.adf-datatable-cell--image {
max-width: $data-table-thumbnail-width;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck,
@Input()
actionsPosition: string = 'right'; // left|right

/** Toggles whether the actions dropdown should only be visible if the row is hovered over or the dropdown menu is open. */
@Input()
actionsVisibleOnHover: boolean = false;

/** Fallback image for rows where the thumbnail is missing. */
@Input()
fallbackThumbnail: string;
Expand Down