Skip to content

🎨 Palette: Improve ImageUploader accessibility#45

Open
MacTechIN wants to merge 1 commit into
mainfrom
palette-image-uploader-a11y-5820012902974999884
Open

🎨 Palette: Improve ImageUploader accessibility#45
MacTechIN wants to merge 1 commit into
mainfrom
palette-image-uploader-a11y-5820012902974999884

Conversation

@MacTechIN

@MacTechIN MacTechIN commented Jun 25, 2026

Copy link
Copy Markdown
Owner

💡 What: Improved the keyboard navigation and screen reader accessibility for the ImageUploader component. Added a visually distinct focus ring for both the primary "Select File" button and the destructive "Remove Image" overlay button. The native hidden file input was also explicitly removed from the accessibility tree, and the icon-only "Remove Image" button received proper ARIA labeling.

🎯 Why: To make the component fully usable and understandable via keyboard navigation and screen readers. Users relying on keyboard navigation can now clearly see which element is focused, and screen reader users will receive proper context instead of encountering confusing hidden inputs or unlabelled icon buttons.

Accessibility:

  • The visually hidden file input (className="hidden") now has tabIndex={-1} and aria-hidden="true" to prevent it from trapping focus or being announced improperly.
  • The "Select File" button features a highly visible blue focus ring when accessed via keyboard navigation.
  • The absolute positioned "Remove Image" icon-only button uses aria-label={t('removeImage')} for screen readers, sets the internal <X /> icon to aria-hidden="true", and utilizes a red focus ring (matched to its destructive action) combined with shadow-lg to prevent clipping within its overflow-hidden container.

A new entry was also added to .Jules/palette.md to document the learnings around handling focus rings for absolute positioned overlay buttons.


PR created automatically by Jules for task 5820012902974999884 started by @MacTechIN


Note

Low Risk
Small presentational and ARIA-only changes in one UI component; no auth, data, or API impact.

Overview
Improves keyboard and screen reader behavior in ImageUploader without changing upload logic.

The hidden file <input> is removed from the tab order and accessibility tree via tabIndex={-1} and aria-hidden="true". The Select File trigger gets visible focus-visible ring styling. The overlay Remove control gets aria-label, the icon is marked aria-hidden, and a red focus-visible ring (with offset) so focus stays visible inside the overflow-hidden preview.

Documents the pattern in .Jules/palette.md for future custom uploaders.

Reviewed by Cursor Bugbot for commit e1912e5. Bugbot is set up for automated code reviews on this repo. Configure here.

- Added `tabIndex={-1}` and `aria-hidden="true"` to the visually hidden file input to properly exclude it from the accessibility tree.
- Added `focus-visible` styling (`focus-visible:ring-blue-500`) to the "Select File" button.
- Added an explicit `aria-label` (using translations) to the "Remove Image" icon-only button, included `aria-hidden="true"` on the internal icon, and added a red `focus-visible` ring.

Co-authored-by: MacTechIN <63564804+MacTechIN@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 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.

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

Copy link
Copy Markdown

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 introduces accessibility enhancements to the ImageUploader component, such as adding focus-visible ring styles, hiding the native file input from screen readers using tabIndex={-1} and aria-hidden="true", and adding an aria-label to the remove button. These learnings are also documented in .Jules/palette.md. The review feedback recommends explicitly setting type="button" on both the "select file" and "remove image" buttons to prevent accidental form submissions if the component is used inside a form.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

<button
onClick={() => fileInputRef.current?.click()}
className="px-3 sm:px-4 py-2 text-sm bg-blue-500 text-white rounded-lg hover:bg-blue-600 active:scale-95 transition-all"
className="px-3 sm:px-4 py-2 text-sm bg-blue-500 text-white rounded-lg hover:bg-blue-600 active:scale-95 transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-blue-500 focus-visible:outline-none"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The button element is missing an explicit type attribute. In HTML and React, buttons default to type="submit" when placed inside a form, which can cause unexpected form submissions if this component is ever rendered within a form context. It is a best practice to explicitly set type="button" for non-submitting buttons.

            type="button"
            className="px-3 sm:px-4 py-2 text-sm bg-blue-500 text-white rounded-lg hover:bg-blue-600 active:scale-95 transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-blue-500 focus-visible:outline-none"

<button
onClick={onClear}
className="absolute top-2 right-2 p-1.5 sm:p-2 bg-red-500 text-white rounded-full hover:bg-red-600 active:scale-95 transition-all shadow-lg"
className="absolute top-2 right-2 p-1.5 sm:p-2 bg-red-500 text-white rounded-full hover:bg-red-600 active:scale-95 transition-all shadow-lg focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-red-500 focus-visible:outline-none"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Similar to the select file button, this destructive "Remove Image" button is missing an explicit type attribute. Explicitly setting type="button" prevents accidental form submissions if the ImageUploader is used inside a form.

Suggested change
className="absolute top-2 right-2 p-1.5 sm:p-2 bg-red-500 text-white rounded-full hover:bg-red-600 active:scale-95 transition-all shadow-lg focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-red-500 focus-visible:outline-none"
type="button"
className="absolute top-2 right-2 p-1.5 sm:p-2 bg-red-500 text-white rounded-full hover:bg-red-600 active:scale-95 transition-all shadow-lg focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-red-500 focus-visible:outline-none"

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