File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,9 @@ function ThreadCard({ frameSync, thread }: ThreadCardProps) {
8181 ) }
8282 data-testid = "thread-card"
8383 elementRef = { cardRef }
84- tabIndex = { - 1 }
84+ tabIndex = { 0 }
85+ role = "article"
86+ aria-label = "Press Enter to scroll annotation into view"
8587 onClick = { e => {
8688 // Prevent click events intended for another action from
8789 // triggering a page scroll.
@@ -91,6 +93,20 @@ function ThreadCard({ frameSync, thread }: ThreadCardProps) {
9193 } }
9294 onMouseEnter = { ( ) => setThreadHovered ( thread . annotation ?? null ) }
9395 onMouseLeave = { ( ) => setThreadHovered ( null ) }
96+ onKeyDown = { e => {
97+ // Simulate default button behavior, where `Enter` and `Space` trigger
98+ // click action
99+ if (
100+ // Trigger event only if the target is the card itself, so that we do
101+ // not scroll to the annotation while editing it, or if the key is
102+ // pressed to interact with a child button or link.
103+ e . target === cardRef . current &&
104+ [ 'Enter' , ' ' ] . includes ( e . key ) &&
105+ thread . annotation
106+ ) {
107+ scrollToAnnotation ( thread . annotation ) ;
108+ }
109+ } }
94110 key = { thread . id }
95111 >
96112 < CardContent > { threadContent } </ CardContent >
You can’t perform that action at this time.
0 commit comments