🎨 Palette: Add accessibility attributes to SectionEditor buttons#550
🎨 Palette: Add accessibility attributes to SectionEditor buttons#550aafre wants to merge 1 commit into
Conversation
Co-authored-by: aafre <8656674+aafre@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request improves accessibility and keyboard navigation in the SectionEditor component by adding explicit button types, ARIA labels, wrapping emoji icons in accessible spans, and applying focus-visible ring styles. The review feedback correctly identifies a critical issue where React state is mutated directly using .splice() on a nested array, and provides an actionable, immutable alternative using map and filter.
| type="button" | ||
| aria-label="Remove item" | ||
| onClick={() => { | ||
| const updatedSections = [...sections]; | ||
| updatedSections[sectionIndex].content.splice(itemIndex, 1); | ||
| setSections(updatedSections); | ||
| }} | ||
| className="bg-red-500 text-white px-3 py-1 rounded hover:bg-red-600" | ||
| className="bg-red-500 text-white px-3 py-1 rounded hover:bg-red-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-red-500" |
There was a problem hiding this comment.
Directly mutating React state by using .splice() on a nested array reference (updatedSections[sectionIndex].content) can prevent React from detecting state changes and trigger unexpected rendering behavior. Instead, update the state immutably using map and filter.
type="button"
aria-label="Remove item"
onClick={() => {
const updatedSections = sections.map((sec, idx) => {
if (idx !== sectionIndex) return sec;
return {
...sec,
content: sec.content.filter((_: any, i: number) => i !== itemIndex),
};
});
setSections(updatedSections);
}}
className="bg-red-500 text-white px-3 py-1 rounded hover:bg-red-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-red-500"
💡 What: Added
type="button", ARIA labels, semanticrole="img"wrappers for emojis, and explicit keyboard focus states (focus-visible) to the inline buttons insideSectionEditor.🎯 Why: To ensure screen reader users understand the purpose of the icon-only buttons (save/cancel) and to provide clear visual feedback for keyboard navigation.
📸 Before/After: Visual change is subtle (addition of focus rings when navigating via keyboard), but screen reader experience is vastly improved.
♿ Accessibility: Added
aria-labelto buttons missing text content, wrapped emojis inaria-hiddenspans, addedtype="button"to prevent accidental form submission behavior, and addedfocus-visibleclasses to all interactive buttons in the component.PR created automatically by Jules for task 13363041532025596295 started by @aafre