Skip to content

feat: add middle click support for workspace rows #9834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Sep 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: update useClickableTableRow implementation
  • Loading branch information
Parkreiner committed Sep 22, 2023
commit f90d9ffaa86bf33d7f62cd2cd9c65a7f9b24562e
30 changes: 20 additions & 10 deletions site/src/hooks/useClickableTableRow.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
import { type TableRowProps } from "@mui/material/TableRow";
import { makeStyles } from "@mui/styles";
import { useClickable, UseClickableResult } from "./useClickable";
import { useClickable, type UseClickableResult } from "./useClickable";

interface UseClickableTableRowResult extends UseClickableResult {
className: string;
hover: true;
}
type UseClickableTableRowResult = UseClickableResult<HTMLTableRowElement> &
TableRowProps & {
className: string;
hover: true;
};

type TableRowOnClickProps = {
[Key in keyof UseClickableTableRowResult as Key extends `on${string}Click`
? Key
: never]: UseClickableTableRowResult[Key];
};

export const useClickableTableRow = (
onClick: () => void,
): UseClickableTableRowResult => {
export const useClickableTableRow = ({
onClick,
...optionalOnClickProps
}: TableRowOnClickProps): UseClickableTableRowResult => {
const styles = useStyles();
const clickable = useClickable(onClick);
const clickableProps = useClickable<HTMLTableRowElement>(onClick);

return {
...clickable,
...clickableProps,
...optionalOnClickProps,
className: styles.row,
hover: true,
};
Expand Down