Skip to content

Commit

Permalink
Refactoring aria-current and icon to simpler ternary from util func.
Browse files Browse the repository at this point in the history
  • Loading branch information
1Copenut committed Sep 14, 2023
1 parent 42226b0 commit d962054
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/components/pagination/pagination_button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export const EuiPaginationButton: FunctionComponent<Props> = ({
{(shortPageString: string) => (
<EuiButtonEmpty
aria-label={totalPages ? longPageString : shortPageString}
aria-current={isActive ? 'true' : undefined}
{...(props as EuiButtonEmptyProps)}
>
{pageNumber}
Expand Down
13 changes: 5 additions & 8 deletions src/components/table/table_pagination/table_pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ export const EuiTablePagination: FunctionComponent<EuiTablePaginationProps> = (
setIsPopoverOpen(false);
}, []);

const setActiveProps = (itemsPerPageOption: number) => {
return itemsPerPageOption === itemsPerPage
? { icon: 'check', 'aria-current': 'true' as const }
: { icon: 'empty', 'aria-current': undefined };
};

const button = (
<EuiButtonEmpty
size="xs"
Expand Down Expand Up @@ -120,7 +114,10 @@ export const EuiTablePagination: FunctionComponent<EuiTablePaginationProps> = (
() =>
itemsPerPageOptions.map((itemsPerPageOption) => (
<EuiContextMenuItem
{...setActiveProps(itemsPerPageOption)}
icon={itemsPerPageOption === itemsPerPage ? 'check' : 'empty'}
aria-current={
itemsPerPageOption === itemsPerPage ? 'true' : undefined
}
key={itemsPerPageOption}
onClick={() => {
closePopover();
Expand All @@ -142,7 +139,7 @@ export const EuiTablePagination: FunctionComponent<EuiTablePaginationProps> = (
)}
</EuiContextMenuItem>
)),
[itemsPerPageOptions, onChangeItemsPerPage, closePopover, setActiveProps]
[itemsPerPageOptions, itemsPerPage, onChangeItemsPerPage, closePopover]
);

const itemsPerPagePopover = (
Expand Down

0 comments on commit d962054

Please sign in to comment.