Skip to content

🎨 Palette: Replace custom interactive divs with native buttons - #604

Open
sheepdestroyer wants to merge 1 commit into
masterfrom
palette-ux-buttons-11937495021812497139
Open

🎨 Palette: Replace custom interactive divs with native buttons#604
sheepdestroyer wants to merge 1 commit into
masterfrom
palette-ux-buttons-11937495021812497139

Conversation

@sheepdestroyer

@sheepdestroyersheepdestroyer commented Aug 27, 2026

Copy link
Copy Markdown
Owner

💡 What: Replaced an interactive tag (used for the clear action) and a custom

(used for the list items) with native elements. Added missing type="button" to all other buttons.
🎯 Why: Native buttons provide out-of-the-box keyboard accessibility (like Space/Enter key support) and semantic meaning for screen readers, unlike tags with href="#" which also cause unintended page jumps.
📸 Before/After: Visuals remain unchanged due to CSS resets applied to the new buttons.
♿ Accessibility: Improved keyboard navigation and screen reader semantics by using native interactive elements.


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

Summary by Sourcery

Replace custom interactive controls with semantically correct native buttons and ensure all buttons explicitly use button type.

Bug Fixes:

  • Prevent unintended page jumps from the annotation clear action by replacing its link-based interaction with a native button.

Enhancements:

  • Improve keyboard accessibility and screen-reader semantics by using native buttons for prompt list items and other button-like controls.
  • Preserve the existing visual presentation of converted controls with button styling resets.

Chores:

  • Document the guidance to prefer native buttons over custom interactive elements.

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 27, 2026

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

Reviewer's Guide

The PR improves semantic and keyboard accessibility in the visualizer by replacing custom or link-based interactions with native buttons, explicitly preventing unintended form submission, and adding CSS resets so the UI remains visually unchanged.

Sequence diagram for accessible prompt selection

sequenceDiagram
participant User
participant Visualizer
participant Browser
User->>Browser: Activate native list-item button
Browser->>Visualizer: onclick selectPrompt(index)
Visualizer->>Browser: Render selected prompt details
Browser-->>User: Show selected state and details
Loading

File-Level Changes

ChangeDetailsFiles
Replaced custom interactive elements with native buttons and added explicit non-submit button types.
  • Converted generated list items from div role=button to button elements, removing manual keyboard handlers.
  • Replaced the hash-link clear action with a styled button to prevent page jumps.
  • Added type="button" to filter, export, annotation, and note-saving controls.
  • Added button reset styling and focus-visible treatment to preserve the existing visual design and keyboard focus feedback.
router/static/visualizer.html
Documented the accessibility pattern for future palette changes.
  • Recorded guidance to prefer native buttons for JavaScript-driven interactions.
.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

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: b1106012-caf1-457c-bb0a-1b3bf4ee6199


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 27, 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 1 issue

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments### Comment 1
<locationpath="router/static/visualizer.html"line_range="258-262" />
<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>
**issue (bug_risk):** The generated `<button>` contains `<div>` elements, which are not permitted inside a button. The HTML parser implicitly closes the button before the first `<div>`, leaving the visible list-item content outside the button, so clicking or keyboard-activating the item does not reliably call `selectPrompt(i)`.
**Triggers:** When the browser parses the dynamically assigned `listEl.innerHTML`.
**Suggested fix:** Replace the nested `<div>` elements with `<span>` elements styled as needed, or use a non-button wrapper containing a separate native button.
```suggestion return `<button type="button" class="list-item${i === selectedIdx ? ' selected' : ''}" onclick="selectPrompt(${i})" aria-label="Prompt ${i}"> <span class="id" style="display:block">#${i} · LLM: ${displayLlm}${pred ? ' · CLS: ' + displayPred : ''}</span> <span class="snippet" style="display:block">${escapeHtml(p.prompt.substring(0, 120))}</span> <span class="tags">${tags}</span> </button>`;```
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: router/static/visualizer.html:262


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 +258 to +262
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.

issue (bug_risk): The generated <button> contains <div> elements, which are not permitted inside a button. The HTML parser implicitly closes the button before the first <div>, leaving the visible list-item content outside the button, so clicking or keyboard-activating the item does not reliably call selectPrompt(i).

Triggers: When the browser parses the dynamically assigned listEl.innerHTML.

Suggested fix: Replace the nested <div> elements with <span> elements styled as needed, or use a non-button wrapper containing a separate native button.

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" style="display:block">#${i} · LLM: ${displayLlm}${pred ? ' · CLS: ' + displayPred : ''}</span>
<spanclass="snippet" style="display:block">${escapeHtml(p.prompt.substring(0, 120))}</span>
<spanclass="tags">${tags}</span>
</button>`;

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