-
-
Notifications
You must be signed in to change notification settings - Fork 9
fix(a11y): convert click-only divs/spans to keyboard-accessible buttons #64
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -554,7 +554,20 @@ export function TimelineTab({ events, tabId, onClear }: TimelineTabProps) { | |
| </div> | ||
|
|
||
| <div className="snapshot-panel"> | ||
| <div className="snapshot-header" onClick={() => setSnapshotPanelOpen(!snapshotPanelOpen)}> | ||
| <div | ||
| className="snapshot-header" | ||
| role="button" | ||
| tabIndex={0} | ||
| aria-expanded={snapshotPanelOpen} | ||
| onClick={() => setSnapshotPanelOpen(!snapshotPanelOpen)} | ||
| onKeyDown={(e) => { | ||
| if (e.target !== e.currentTarget) return; | ||
| if (e.key === 'Enter' || e.key === ' ') { | ||
| e.preventDefault(); | ||
| setSnapshotPanelOpen(!snapshotPanelOpen); | ||
| } | ||
| }} | ||
| > | ||
| <span className="snapshot-toggle">{snapshotPanelOpen ? '▼' : '▶'}</span> | ||
| <span className="snapshot-title">Snapshots ({snapshots.length})</span> | ||
|
Comment on lines
+557
to
572
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Applying Instead of making the entire header a button and using target checks to prevent event bubbling, wrap only the toggle icon and title in a separate |
||
| <button | ||
|
|
@@ -579,7 +592,17 @@ export function TimelineTab({ events, tabId, onClear }: TimelineTabProps) { | |
| <div key={snapshot.id} className={`snapshot-item ${expandedSnapshotId === snapshot.id ? 'expanded' : ''}`}> | ||
| <div | ||
| className="snapshot-item-header" | ||
| role="button" | ||
| tabIndex={0} | ||
| aria-expanded={expandedSnapshotId === snapshot.id} | ||
| onClick={() => setExpandedSnapshotId(expandedSnapshotId === snapshot.id ? null : snapshot.id)} | ||
| onKeyDown={(e) => { | ||
| if (e.target !== e.currentTarget) return; | ||
| if (e.key === 'Enter' || e.key === ' ') { | ||
| e.preventDefault(); | ||
| setExpandedSnapshotId(expandedSnapshotId === snapshot.id ? null : snapshot.id); | ||
| } | ||
| }} | ||
| > | ||
| <span className="snapshot-time"> | ||
| {new Date(snapshot.createdAt).toLocaleTimeString()} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applying
role="button"to the entire.ai-item-cardcontainer makes all of its content—including the description, suggestions, and affected components inside.ai-item-bodywhen expanded—part of the button's accessible content. This is an accessibility anti-pattern because buttons should not contain complex structured or interactive content.Instead, only the
.ai-item-headershould act as the interactive toggle button, keeping the.ai-item-bodysemantically separate.