Skip to content

🎨 Palette: Add accessibility attributes to SectionEditor buttons#550

Open
aafre wants to merge 1 commit into
mainfrom
palette-section-editor-a11y-13363041532025596295
Open

🎨 Palette: Add accessibility attributes to SectionEditor buttons#550
aafre wants to merge 1 commit into
mainfrom
palette-section-editor-a11y-13363041532025596295

Conversation

@aafre
Copy link
Copy Markdown
Owner

@aafre aafre commented May 25, 2026

💡 What: Added type="button", ARIA labels, semantic role="img" wrappers for emojis, and explicit keyboard focus states (focus-visible) to the inline buttons inside SectionEditor.
🎯 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-label to buttons missing text content, wrapped emojis in aria-hidden spans, added type="button" to prevent accidental form submission behavior, and added focus-visible classes to all interactive buttons in the component.


PR created automatically by Jules for task 13363041532025596295 started by @aafre

Co-authored-by: aafre <8656674+aafre@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +157 to +164
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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant