Skip to content

Commit fae7b72

Browse files
feedback
1 parent 5b7b01b commit fae7b72

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

  • packages/web/src/app/(app)/browse/[...path]/components/commitHistoryPanel

packages/web/src/app/(app)/browse/[...path]/components/commitHistoryPanel/commitRow.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ export const CommitRow = ({ commit, repoName, revisionName }: CommitRowProps) =>
5858
return true;
5959
}, [commit.hash, toast]);
6060

61+
const navigateToCommit = useCallback(() => {
62+
router.push(commitDiffHref);
63+
}, [router, commitDiffHref]);
64+
6165
// Navigate to the commit diff when the row is clicked, unless the click
6266
// originated from an interactive child (button or link) — those keep their
6367
// own behavior (copy SHA, view file/repo at commit, expand body, etc.).
@@ -66,14 +70,26 @@ export const CommitRow = ({ commit, repoName, revisionName }: CommitRowProps) =>
6670
if (target.closest('button, a')) {
6771
return;
6872
}
69-
router.push(commitDiffHref);
70-
}, [router, commitDiffHref]);
73+
navigateToCommit();
74+
}, [navigateToCommit]);
75+
76+
const onRowKeyDown = useCallback((event: React.KeyboardEvent<HTMLDivElement>) => {
77+
if ((event.target as HTMLElement).closest('button, a')) {
78+
return;
79+
}
80+
if (event.key === 'Enter') {
81+
navigateToCommit();
82+
}
83+
}, [navigateToCommit]);
7184

7285
return (
7386
<>
7487
<div
88+
role="link"
89+
tabIndex={0}
7590
className="flex flex-row py-3 px-3 items-center justify-between gap-4 min-w-0 border-b cursor-pointer hover:bg-muted"
7691
onClick={onRowClick}
92+
onKeyDown={onRowKeyDown}
7793
>
7894
<div className="flex flex-col gap-1 min-w-0 overflow-hidden">
7995
<div className="flex flex-row items-center gap-2 min-w-0 overflow-hidden">

0 commit comments

Comments
 (0)