From 3aa3ba19d4a0b7c2425a0f26fee64a15a8457977 Mon Sep 17 00:00:00 2001 From: Cee Chen Date: Fri, 5 Apr 2024 14:27:07 -0700 Subject: [PATCH] =?UTF-8?q?clean=20up=20even=20more=20things!!=20?= =?UTF-8?q?=F0=9F=A7=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit i can't be stopped. no one can stop me --- .../__snapshots__/basic_table.test.tsx.snap | 1 - .../table_header_cell.test.tsx.snap | 5 -- src/components/table/table_header_cell.tsx | 83 ++++++++----------- 3 files changed, 33 insertions(+), 56 deletions(-) diff --git a/src/components/basic_table/__snapshots__/basic_table.test.tsx.snap b/src/components/basic_table/__snapshots__/basic_table.test.tsx.snap index 4ed70fc8a71d..3fa583c6f2a1 100644 --- a/src/components/basic_table/__snapshots__/basic_table.test.tsx.snap +++ b/src/components/basic_table/__snapshots__/basic_table.test.tsx.snap @@ -161,7 +161,6 @@ exports[`EuiBasicTable renders (kitchen sink) with pagination, selection, sortin = ({ const CellComponent = children ? 'th' : 'td'; const cellScope = CellComponent === 'th' ? scope ?? 'col' : undefined; // `scope` is only valid on `th` elements - const cellContents = ( - - {children} - - ); - - if (onSort || isSorted) { - const buttonClasses = classNames('euiTableHeaderButton', { - 'euiTableHeaderButton-isSorted': isSorted, - }); - - let ariaSortValue: HTMLAttributes['aria-sort'] = 'none'; - if (isSorted) { - ariaSortValue = isSortAscending ? 'ascending' : 'descending'; - } - - return ( - - {onSort && !readOnly ? ( - - ) : ( - cellContents - )} - - ); + const canSort = !!(onSort && !readOnly); + let ariaSortValue: HTMLAttributes['aria-sort']; + if (isSorted) { + ariaSortValue = isSortAscending ? 'ascending' : 'descending'; + } else if (canSort) { + ariaSortValue = 'none'; } + const cellContentsProps = { + css: styles.euiTableHeaderCell__content, + align, + description, + canSort, + isSorted, + isSortAscending, + children, + }; + return ( - {cellContents} + {canSort ? ( + + ) : ( + + )} ); };