-
Notifications
You must be signed in to change notification settings - Fork 0
π¨ Palette: Add dynamic aria-labels to icon-only buttons #53
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 2024-06-06 - Dynamic Accessibility Labels in React | ||
| **Learning:** Found a pattern where interactive elements (like the SpatialWorkspace delete buttons) use a two-step confirm process managed entirely via local React state without text labels. If aria-labels don't adapt to the current UI state, screen readers will hear "Delete" even when the visual UI says "Confirm?". | ||
| **Action:** Always bind `aria-label`s to the same state variable that drives the text or icon conditional rendering so accessibility state perfectly mirrors visual state. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1450,6 +1450,7 @@ export default function SpatialWorkspace({ | |||||||||||||||||||||
| setEditingItemType("vault"); | ||||||||||||||||||||||
| setEditValue(vault.name); | ||||||||||||||||||||||
| }} | ||||||||||||||||||||||
| aria-label={`Edit ${vault.name}`} | ||||||||||||||||||||||
| > | ||||||||||||||||||||||
| βοΈ | ||||||||||||||||||||||
| </button> | ||||||||||||||||||||||
|
|
@@ -1459,6 +1460,11 @@ export default function SpatialWorkspace({ | |||||||||||||||||||||
| className={`spatial-card-action-btn ${deleteArmedId === vault.id ? "delete-armed" : ""}`} | ||||||||||||||||||||||
| onClick={(e) => handleArmDelete(e, vault.id)} | ||||||||||||||||||||||
| title="Click twice to delete vault card" | ||||||||||||||||||||||
| aria-label={ | ||||||||||||||||||||||
| deleteArmedId === vault.id | ||||||||||||||||||||||
| ? `Confirm delete ${vault.name}` | ||||||||||||||||||||||
| : `Delete ${vault.name}` | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+1463
to
+1467
Contributor
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. The delete button is rendered for all vaults, including those that are redacted and locked. Directly using
Suggested change
|
||||||||||||||||||||||
| > | ||||||||||||||||||||||
| {deleteArmedId === vault.id ? "Confirm?" : "ποΈ"} | ||||||||||||||||||||||
| </button> | ||||||||||||||||||||||
|
|
@@ -1575,6 +1581,7 @@ export default function SpatialWorkspace({ | |||||||||||||||||||||
| setEditingItemType("node"); | ||||||||||||||||||||||
| setEditValue(node.title); | ||||||||||||||||||||||
| }} | ||||||||||||||||||||||
| aria-label={`Edit ${node.title}`} | ||||||||||||||||||||||
|
Contributor
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. |
||||||||||||||||||||||
| > | ||||||||||||||||||||||
| βοΈ | ||||||||||||||||||||||
| </button> | ||||||||||||||||||||||
|
|
@@ -1586,6 +1593,11 @@ export default function SpatialWorkspace({ | |||||||||||||||||||||
| e.stopPropagation(); | ||||||||||||||||||||||
| handleArmDelete(e, node.id); | ||||||||||||||||||||||
| }} | ||||||||||||||||||||||
| aria-label={ | ||||||||||||||||||||||
| deleteArmedId === node.id | ||||||||||||||||||||||
| ? `Confirm delete ${node.title}` | ||||||||||||||||||||||
| : `Delete ${node.title}` | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+1596
to
+1600
Contributor
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. Directly using
Suggested change
|
||||||||||||||||||||||
| > | ||||||||||||||||||||||
| {deleteArmedId === node.id ? "Ok?" : "ποΈ"} | ||||||||||||||||||||||
| </button> | ||||||||||||||||||||||
|
|
@@ -1657,6 +1669,7 @@ export default function SpatialWorkspace({ | |||||||||||||||||||||
| setEditingItemType("subvault"); | ||||||||||||||||||||||
| setEditValue(subvault.name); | ||||||||||||||||||||||
| }} | ||||||||||||||||||||||
| aria-label={`Edit ${subvault.name}`} | ||||||||||||||||||||||
|
Contributor
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. To prevent potential privacy leaks of redacted subvault names, use the privacy-safe display label helper
Suggested change
|
||||||||||||||||||||||
| > | ||||||||||||||||||||||
| βοΈ | ||||||||||||||||||||||
| </button> | ||||||||||||||||||||||
|
|
@@ -1668,6 +1681,11 @@ export default function SpatialWorkspace({ | |||||||||||||||||||||
| e.stopPropagation(); | ||||||||||||||||||||||
| handleArmDelete(e, subvault.id); | ||||||||||||||||||||||
| }} | ||||||||||||||||||||||
| aria-label={ | ||||||||||||||||||||||
| deleteArmedId === subvault.id | ||||||||||||||||||||||
| ? `Confirm delete ${subvault.name}` | ||||||||||||||||||||||
| : `Delete ${subvault.name}` | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+1684
to
+1688
Contributor
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. Directly using
Suggested change
|
||||||||||||||||||||||
| > | ||||||||||||||||||||||
| {deleteArmedId === subvault.id ? "Ok?" : "ποΈ"} | ||||||||||||||||||||||
| </button> | ||||||||||||||||||||||
|
|
@@ -1753,6 +1771,7 @@ export default function SpatialWorkspace({ | |||||||||||||||||||||
| setEditingItemType("node"); | ||||||||||||||||||||||
| setEditValue(node.title); | ||||||||||||||||||||||
| }} | ||||||||||||||||||||||
| aria-label={`Edit ${node.title}`} | ||||||||||||||||||||||
|
Contributor
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. |
||||||||||||||||||||||
| > | ||||||||||||||||||||||
| βοΈ | ||||||||||||||||||||||
| </button> | ||||||||||||||||||||||
|
|
@@ -1764,6 +1783,11 @@ export default function SpatialWorkspace({ | |||||||||||||||||||||
| e.stopPropagation(); | ||||||||||||||||||||||
| handleArmDelete(e, node.id); | ||||||||||||||||||||||
| }} | ||||||||||||||||||||||
| aria-label={ | ||||||||||||||||||||||
| deleteArmedId === node.id | ||||||||||||||||||||||
| ? `Confirm delete ${node.title}` | ||||||||||||||||||||||
| : `Delete ${node.title}` | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+1786
to
+1790
Contributor
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. Directly using
Suggested change
|
||||||||||||||||||||||
| > | ||||||||||||||||||||||
| {deleteArmedId === node.id ? "Ok?" : "ποΈ"} | ||||||||||||||||||||||
| </button> | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
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.
The
aria-labeldirectly exposesvault.nameto screen readers. To prevent potential privacy leaks of redacted vault names, use the privacy-safe display label helpergetPrivacyDisplayLabel.