Skip to content

Commit 3584a84

Browse files
authored
HParams: Make icons buttons in data table header (#6594)
## Motivation for features / changes To allow for tabbing to buttons and for general best practice clickable elements should be buttons. So the 3 dot menu button was changed into a button instead of a div. For sorting the entire header is clickable. We did not want to make the entire header a button so I turned the sorting icon into a button. I also made some styling changes to spread out the icons and make them easier to click. ## Technical description of changes When I made the sorting icon a button I had to add the click event to make it sort. I also had to stop propagation so the header's click event was not fired. ## Screenshots of UI changes (or N/A) ![2023-09-22_11-05-35 (1)](https://github.com/tensorflow/tensorboard/assets/8672809/29b33b4c-6122-49fd-b299-b55a12d69011)
1 parent f8d64c8 commit 3584a84

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

Diff for: tensorboard/webapp/widgets/data_table/header_cell_component.ng.html

+12-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
>
2424
<ng-content></ng-content>
2525
<tb-data-table-header [header]="header"></tb-data-table-header>
26-
<div *ngIf="header.sortable" class="sorting-icon-container">
26+
<button
27+
mat-icon-button
28+
*ngIf="header.sortable"
29+
class="sorting-icon-container"
30+
(click)="$event.stopPropagation(); headerClickedHandler()"
31+
>
2732
<mat-icon
2833
*ngIf="
2934
sortingInfo.order === SortingOrder.ASCENDING ||
@@ -44,14 +49,13 @@
4449
"
4550
svgIcon="arrow_downward_24px"
4651
></mat-icon>
47-
</div>
48-
<div
52+
</button>
53+
<button
54+
mat-icon-button
4955
*ngIf="(header.removable || header.sortable) && !disableContextMenu"
5056
class="context-menu-container show-on-hover"
57+
(click)="onContextMenuOpened($event)"
5158
>
52-
<mat-icon
53-
(click)="onContextMenuOpened($event)"
54-
svgIcon="more_vert_24px"
55-
></mat-icon>
56-
</div>
59+
<mat-icon svgIcon="more_vert_24px"></mat-icon>
60+
</button>
5761
</div>

Diff for: tensorboard/webapp/widgets/data_table/header_cell_component.scss

+9-2
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,20 @@ $_icon_size: 12px;
3434
&:hover {
3535
opacity: 1;
3636
}
37+
&:focus {
38+
opacity: 1;
39+
}
3740
}
3841
}
3942

4043
.sorting-icon-container,
4144
.context-menu-container {
42-
width: $_icon_size;
43-
height: $_icon_size;
45+
width: $_icon_size + 4px;
46+
height: $_icon_size + 4px;
4447
border-radius: 5px;
48+
display: flex;
49+
justify-content: center;
50+
align-items: center;
4551
}
4652

4753
.cell {
@@ -51,6 +57,7 @@ $_icon_size: 12px;
5157
mat-icon {
5258
height: $_icon_size;
5359
width: $_icon_size;
60+
line-height: 1;
5461
}
5562

5663
.sorting-icon-container {

0 commit comments

Comments
 (0)