Skip to content

🎨 Palette: Improve interactive element accessibility - #599

Open
sheepdestroyer wants to merge 4 commits into
masterfrom
palette-a11y-buttons-13223841212063358673
Open

🎨 Palette: Improve interactive element accessibility#599
sheepdestroyer wants to merge 4 commits into
masterfrom
palette-a11y-buttons-13223841212063358673

Conversation

@sheepdestroyer

@sheepdestroyersheepdestroyer commented Aug 26, 2026

Copy link
Copy Markdown
Owner

💡 What: Replaced custom interactive div list items and a tags with semantic <button type="button"> elements.
🎯 Why: Custom divs with role="button" and tabindex="0" require manual keydown handlers and don't provide native button behavior. Using <a href="#"> for actions causes unexpected scrolling. Using native buttons improves screen reader compatibility and semantic HTML.
📸 Before/After: Visually identical, but functionally superior.
♿ Accessibility: Improved keyboard interaction parity and screen reader semantics by using native interactive elements.


PR created automatically by Jules for task 13223841212063358673 started by @sheepdestroyer

Summary by Sourcery

Use native buttons for visualizer interactions to provide consistent keyboard and screen-reader behavior.

Bug Fixes:

  • Remove action links that caused unintended page scrolling when clearing annotations.

Enhancements:

  • Improve visualizer keyboard accessibility and semantic behavior by replacing custom prompt list controls and action links with native buttons while preserving their appearance.

Chores:

  • Record accessibility guidance for interactive controls in the project learning notes.

Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@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.

@sourcery-ai

sourcery-aiBot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Improves Palette accessibility by replacing custom role-based list items and JavaScript action links with semantic native buttons, adding CSS resets to preserve the existing appearance while gaining native keyboard and screen-reader behavior.

Flow diagram for semantic Palette interactions

flowchart LR
User[User] --> PromptButton[Native prompt button]
PromptButton --> SelectPrompt[selectPrompt]
SelectPrompt --> Visualizer[Updated visualizer]
User --> ClearButton[Native clear button]
ClearButton --> ClearAnnotation[clearAnnotation]
ClearAnnotation --> ReviewState[Updated review state]
Loading

File-Level Changes

ChangeDetailsFiles
Replace custom prompt list interactions with native buttons while preserving the existing visual styling and selection behavior.
  • Render each prompt item as a <button type="button"> instead of a focusable, role-mapped div.
  • Add button CSS resets and layout rules so native controls remain visually identical.
  • Remove manual Enter/Space keyboard handling in favor of native button behavior.
router/static/visualizer.html
Replace the annotation-clearing action link with an inline native button to avoid link navigation side effects.
  • Use <button type="button"> for the clear action while retaining its inline visual treatment and click handler.
router/static/visualizer.html
Document the accessibility implementation guidance for interactive list controls.
  • Record the recommendation to use native buttons and CSS resets for custom-styled actions.
  • Document avoiding href="#" links for JavaScript-only actions.
.Jules/palette.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitaiBot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f9ecdf9e-9d40-4f9c-8a6e-f0a5bbe9459b


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation router labels Aug 26, 2026

@sourcery-aisourcery-aiBot left a comment

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.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments### Comment 1
<locationpath="router/static/visualizer.html"line_range="255-259" />
<code_context>
const displayPred = pred ? escapeHtml(pred.replace('agent-','')) : '';
- return `<divclass="list-item${i === selectedIdx ? ' selected' : ''}"onclick="selectPrompt(${i})"tabindex="0"role="button"aria-label="Prompt ${i}"onkeydown="if(event.key==='Enter'||event.key===''){event.preventDefault();selectPrompt(${i})}">
+ return `<buttontype="button"class="list-item${i === selectedIdx ? ' selected' : ''}"onclick="selectPrompt(${i})"aria-label="Prompt ${i}">
<divclass="id">#${i} · LLM: ${displayLlm}${pred ? ' · CLS: ' + displayPred : ''}</div>
<divclass="snippet">${escapeHtml(p.prompt.substring(0, 120))}</div>
<divclass="tags">${tags}</div>
- </div>`;
+ </button>`;
}).join('');
</code_context>
<issue_to_address>
**nitpick (bug_risk):** Each new `<button>` contains `<div>` children, but a button's content model is phrasing content and `<div>` is flow content. The generated markup is non-conforming HTML and is reported as invalid by HTML validators, undermining the semantic-HTML goal of the change.
**Suggested fix:** Use phrasing elements such as `<span>` for the button's contents, or keep the existing block structure outside the button while styling the button itself.
```suggestion return `<button type="button" class="list-item${i === selectedIdx ? ' selected' : ''}" onclick="selectPrompt(${i})" aria-label="Prompt ${i}"> <span class="id">#${i} · LLM: ${displayLlm}${pred ? ' · CLS: ' + displayPred : ''}</span> <span class="snippet">${escapeHtml(p.prompt.substring(0, 120))}</span> <span class="tags">${tags}</span> </button>`;```
</issue_to_address>
### Comment 2
<locationpath=".Jules/palette.md"line_range="25-27" />
<code_context>
+## 2024-08-26 - Interactive element accessibility in custom lists
</code_context>
<issue_to_address>
**nitpick:** The new 2024-08-26 palette entry is appended after a 2026-08-16 entry, so the learning log is no longer in chronological order and presents its history misleadingly.
**Suggested fix:** Insert the 2024-08-26 entry before the 2026 entries, or update the date if 2024-08-26 is a typo.
</issue_to_address>

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +255 to +259
return `<button type="button" class="list-item${i === selectedIdx ? ' selected' : ''}" onclick="selectPrompt(${i})" aria-label="Prompt ${i}">
<div class="id">#${i} · LLM: ${displayLlm}${pred ? ' · CLS: ' + displayPred : ''}</div>
<div class="snippet">${escapeHtml(p.prompt.substring(0, 120))}</div>
<div class="tags">${tags}</div>
</div>`;
</button>`;

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.

nitpick (bug_risk): Each new <button> contains <div> children, but a button's content model is phrasing content and <div> is flow content. The generated markup is non-conforming HTML and is reported as invalid by HTML validators, undermining the semantic-HTML goal of the change.

Suggested fix: Use phrasing elements such as <span> for the button's contents, or keep the existing block structure outside the button while styling the button itself.

Suggested change
return `<buttontype="button" class="list-item${i === selectedIdx ? ' selected' : ''}" onclick="selectPrompt(${i})" aria-label="Prompt ${i}">
<divclass="id">#${i} · LLM: ${displayLlm}${pred ? ' · CLS: ' + displayPred : ''}</div>
<divclass="snippet">${escapeHtml(p.prompt.substring(0, 120))}</div>
<divclass="tags">${tags}</div>
</div>`;
</button>`;
return `<buttontype="button" class="list-item${i === selectedIdx ? ' selected' : ''}" onclick="selectPrompt(${i})" aria-label="Prompt ${i}">
<spanclass="id">#${i} · LLM: ${displayLlm}${pred ? ' · CLS: ' + displayPred : ''}</span>
<spanclass="snippet">${escapeHtml(p.prompt.substring(0, 120))}</span>
<spanclass="tags">${tags}</span>
</button>`;

Comment thread.Jules/palette.md
Comment on lines +25 to +27
## 2024-08-26 - Interactive element accessibility in custom lists
**Learning:** Custom interactive elements that act as buttons (e.g. `div` with `role="button"` and `tabindex="0"`) lack semantic meaning and require manual Javascript event handlers for keyboard events (like `Enter` and `Space`). Additionally, using `<a href="#">` with `onclick` for Javascript actions causes unintended page jumps.
**Action:** Replace interactive `div` elements with native `<button type="button">` elements and apply CSS resets (`display: block`, `width: 100%`, `text-align: left`, `background: transparent`, `border: none`, `color: inherit`, `font-family: inherit`) to retain visual styling while gaining native accessibility features. Replace Javascript action links (`<a href="#">`) with inline `<button type="button">`.

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.

nitpick: The new 2024-08-26 palette entry is appended after a 2026-08-16 entry, so the learning log is no longer in chronological order and presents its history misleadingly.

Suggested fix: Insert the 2024-08-26 entry before the 2026 entries, or update the date if 2024-08-26 is a typo.

google-labs-julesBotand others added 3 commits August 26, 2026 05:33
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentationrouter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@sheepdestroyer