Skip to content

Commit 80be7ed

Browse files
committed
refactor: update props definition for PaginationNavButton
1 parent 964cc2d commit 80be7ed

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

site/src/components/PaginationWidget/PaginationNavButton.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
1-
import { type ReactNode, useEffect, useState } from "react";
1+
import {
2+
type ButtonHTMLAttributes,
3+
type ReactNode,
4+
useEffect,
5+
useState,
6+
} from "react";
7+
import { useTheme } from "@emotion/react";
28

39
import Button from "@mui/material/Button";
410
import Tooltip from "@mui/material/Tooltip";
5-
import { useTheme } from "@emotion/react";
611

7-
type PaginationNavButtonProps = {
12+
type PaginationNavButtonProps = Omit<
13+
ButtonHTMLAttributes<HTMLButtonElement>,
14+
"aria-disabled" | "color"
15+
> & {
16+
// Required/narrowed versions of default props
817
children: ReactNode;
918
disabled: boolean;
10-
disabledMessage: ReactNode;
1119
onClick: () => void;
1220
"aria-label": string;
1321

22+
// Bespoke props
23+
disabledMessage: ReactNode;
1424
disabledMessageTimeout?: number;
1525
};
1626

1727
export function PaginationNavButton({
18-
children,
1928
onClick,
2029
disabled,
2130
disabledMessage,
22-
"aria-label": ariaLabel,
2331
disabledMessageTimeout = 3000,
32+
...delegatedProps
2433
}: PaginationNavButtonProps) {
2534
const theme = useTheme();
2635
const [showDisabledMessage, setShowDisabledMessage] = useState(false);
@@ -56,7 +65,6 @@ export function PaginationNavButton({
5665
* (mostly for giving direct UI feedback to those actions)
5766
*/}
5867
<Button
59-
aria-label={ariaLabel}
6068
aria-disabled={disabled}
6169
css={
6270
disabled && {
@@ -76,9 +84,8 @@ export function PaginationNavButton({
7684
onClick();
7785
}
7886
}}
79-
>
80-
{children}
81-
</Button>
87+
{...delegatedProps}
88+
/>
8289
</Tooltip>
8390
);
8491
}

0 commit comments

Comments
 (0)