diff --git a/src/css/manage/_snippets-table.scss b/src/css/manage/_snippets-table.scss index e0e7e9aa..5a37fb8d 100644 --- a/src/css/manage/_snippets-table.scss +++ b/src/css/manage/_snippets-table.scss @@ -85,9 +85,27 @@ list-style: disc; } - th.sortable a, th.sorted a { + th.sortable .list-table-sort-button, + th.sorted .list-table-sort-button { display: flex; flex-direction: row; + align-items: center; + inline-size: 100%; + margin: 0; + padding: 0; + border: none; + background: none; + font: inherit; + color: #2271b1; + cursor: pointer; + text-align: start; + } + + th.sortable .list-table-sort-button:focus-visible, + th.sorted .list-table-sort-button:focus-visible { + outline: 2px solid #2271b1; + outline-offset: 2px; + border-radius: 2px; } .row-actions { @@ -157,7 +175,6 @@ #wpbody-content & .column-name { white-space: nowrap; /* prevents wrapping of snippet title */ - vertical-align: top; } td.column-date, th.column-date { diff --git a/src/js/components/common/ListTable/TableHeadings.tsx b/src/js/components/common/ListTable/TableHeadings.tsx index 85e3885e..c65816b3 100644 --- a/src/js/components/common/ListTable/TableHeadings.tsx +++ b/src/js/components/common/ListTable/TableHeadings.tsx @@ -13,7 +13,7 @@ export interface TableHeadingsProps extends Pick> } -interface SortableColumnHeadingProps { +interface SortableHeadingCellProps { column: ListTableColumn cellProps: ThHTMLAttributes sortColumn: ListTableColumn | undefined @@ -22,11 +22,15 @@ interface SortableColumnHeadingProps { setSortDirection: Dispatch> } -const SortableColumnHeading = ({ - column, cellProps, sortColumn, sortDirection, setSortColumn, setSortDirection -}: SortableColumnHeadingProps) => { +const SortableHeadingCell = ({ + column, + cellProps, + sortColumn, + sortDirection, + setSortColumn, + setSortDirection +}: SortableHeadingCellProps) => { const isCurrent = column.id === sortColumn?.id - const nextSortDirection = isCurrent ? 'asc' === sortDirection ? 'desc' : 'asc' : column.defaultSortDirection ?? 'asc' @@ -39,11 +43,14 @@ const SortableColumnHeading = ({ aria-sort={ariaSort} className={classnames(cellProps.className, isCurrent ? 'sorted' : 'sortable', classDirection)} > - { - event.preventDefault() - setSortColumn(column) - setSortDirection(nextSortDirection) - }}> + ) } @@ -87,7 +94,6 @@ export const TableHeadings = ({ {columns.map(column => { const cellProps: ThHTMLAttributes = { id: 'head' === which ? column.id.toString() : undefined, - key: column.id, scope: 'col', className: classnames( 'manage-column', @@ -97,8 +103,13 @@ export const TableHeadings = ({ ) } - return column.sortedValue - ? - : {column.title} + if (!column.sortedValue) { + return {column.title} + } + + return })}