🎨 Palette: Make delete conversation button accessible#98
🎨 Palette: Make delete conversation button accessible#98Dexploarer wants to merge 1 commit intomainfrom
Conversation
- Add `aria-label="Delete conversation"` to the sidebar delete button. - Wrap the "×" character in a `span` with `aria-hidden="true"`. - Add `focus:opacity-100` class to make the button visible on keyboard focus. - Add unit test to verify accessibility attributes and focus behavior.
|
👋 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. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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. Comment |
Summary of ChangesHello @Dexploarer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the user experience for individuals relying on keyboard navigation and screen readers by making the "delete conversation" button in the sidebar fully accessible. The changes address previous visibility issues on hover and ensure proper semantic labeling, supported by new test coverage and a documented learning note on accessibility best practices. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| void handleDeleteConversation(conv.id); | ||
| }} |
There was a problem hiding this comment.
Potential for Accidental Deletion
The delete button immediately deletes a conversation upon click without any confirmation dialog. This can lead to accidental data loss if the user clicks the button unintentionally.
Recommendation:
Prompt the user for confirmation before proceeding with the deletion. For example:
if (window.confirm('Are you sure you want to delete this conversation?')) {
void handleDeleteConversation(conv.id);
}| className="opacity-100 sm:opacity-0 sm:group-hover:opacity-100 focus:opacity-100 transition-opacity border-none bg-transparent text-muted hover:text-danger hover:bg-destructive-subtle cursor-pointer text-sm px-1 py-0.5 rounded flex-shrink-0" | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| void handleDeleteConversation(conv.id); |
There was a problem hiding this comment.
Lack of Error Handling for Asynchronous Deletion
The call to handleDeleteConversation is marked as void, and any errors during the deletion process are ignored. If the deletion fails (e.g., due to a network error), the user receives no feedback and the UI may become inconsistent.
Recommendation:
Handle errors from the asynchronous operation and provide user feedback. For example:
try {
await handleDeleteConversation(conv.id);
} catch (error) {
// Show an error message to the user
}| const deleteButton = root.findByProps({ "data-testid": "conv-delete" }); | ||
|
|
There was a problem hiding this comment.
Potential brittleness in element lookup:
The use of root.findByProps({ "data-testid": "conv-delete" }) will throw an error if the element is not found, which can make the test brittle and harder to debug. Consider using a safer lookup method, such as filtering children or using try/catch to provide a clearer error message if the element is missing.
Recommended solution:
let deleteButton;
try {
deleteButton = root.findByProps({ "data-testid": "conv-delete" });
} catch (e) {
throw new Error("Delete button not found. Check ConversationsSidebar rendering.");
}This approach improves error handling and test maintainability.
There was a problem hiding this comment.
Code Review
The pull request effectively addresses accessibility concerns for the delete conversation button. The changes introduce aria-label for screen readers, focus:opacity-100 for keyboard users, and aria-hidden="true" for the visual '×' to prevent misinterpretation by screen readers. The new test case also validates these accessibility improvements, which is a good practice.
| ## 2025-05-24 - Accessibility of Hover-State Actions | ||
| **Learning:** Actions that are only visible on hover (like delete buttons in lists) are invisible to keyboard users and screen readers unless specific focus styles and ARIA labels are added. | ||
| **Action:** Always add `focus:opacity-100` (or equivalent) to elements with `opacity-0 group-hover:opacity-100`, and ensure they have `aria-label`. |
| $ vite | ||
|
|
||
| VITE v5.4.21 ready in 486 ms | ||
|
|
||
| ➜ Local: http://localhost:2138/ | ||
| ➜ Network: http://192.168.0.2:2138/ | ||
| 10:55:17 PM [vite] http proxy error: /api/drop/status | ||
| AggregateError [ECONNREFUSED]: | ||
| at internalConnectMultiple (node:net:1134:18) | ||
| at afterConnectMultiple (node:net:1715:7) | ||
| 10:55:17 PM [vite] http proxy error: /api/workbench/overview | ||
| AggregateError [ECONNREFUSED]: | ||
| at internalConnectMultiple (node:net:1134:18) | ||
| at afterConnectMultiple (node:net:1715:7) | ||
| 10:55:17 PM [vite] http proxy error: /api/drop/status | ||
| AggregateError [ECONNREFUSED]: | ||
| at internalConnectMultiple (node:net:1134:18) | ||
| at afterConnectMultiple (node:net:1715:7) | ||
| 10:55:17 PM [vite] http proxy error: /api/conversations/c1/messages | ||
| AggregateError [ECONNREFUSED]: | ||
| at internalConnectMultiple (node:net:1134:18) | ||
| at afterConnectMultiple (node:net:1715:7) | ||
| 10:55:17 PM [vite] ws proxy error: | ||
| AggregateError [ECONNREFUSED]: | ||
| at internalConnectMultiple (node:net:1134:18) | ||
| at afterConnectMultiple (node:net:1715:7) | ||
| 10:55:17 PM [vite] http proxy error: /api/workbench/overview | ||
| AggregateError [ECONNREFUSED]: | ||
| at internalConnectMultiple (node:net:1134:18) | ||
| at afterConnectMultiple (node:net:1715:7) | ||
| 10:55:17 PM [vite] ws proxy error: | ||
| AggregateError [ECONNREFUSED]: | ||
| at internalConnectMultiple (node:net:1134:18) | ||
| at afterConnectMultiple (node:net:1715:7) | ||
| 10:55:17 PM [vite] http proxy error: /api/agent/events?limit=300 | ||
| AggregateError [ECONNREFUSED]: | ||
| at internalConnectMultiple (node:net:1134:18) | ||
| at afterConnectMultiple (node:net:1715:7) |
There was a problem hiding this comment.
| import React from "react"; | ||
| import TestRenderer, { act } from "react-test-renderer"; | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; | ||
| import { ConversationsSidebar } from "../../src/components/ConversationsSidebar"; | ||
|
|
||
| // Mock useApp | ||
| const mockUseApp = vi.fn(); | ||
|
|
||
| vi.mock("../../src/AppContext", () => ({ | ||
| useApp: () => mockUseApp(), | ||
| })); | ||
|
|
||
| describe("ConversationsSidebar", () => { | ||
| beforeEach(() => { | ||
| mockUseApp.mockReset(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| vi.restoreAllMocks(); | ||
| }); | ||
|
|
||
| it("renders delete button with accessible attributes and focus styles", async () => { | ||
| mockUseApp.mockReturnValue({ | ||
| conversations: [ | ||
| { id: "c1", title: "Chat 1", updatedAt: new Date().toISOString() }, | ||
| ], | ||
| activeConversationId: "c1", | ||
| unreadConversations: new Set(), | ||
| handleNewConversation: vi.fn(), | ||
| handleSelectConversation: vi.fn(), | ||
| handleDeleteConversation: vi.fn(), | ||
| handleRenameConversation: vi.fn(), | ||
| }); | ||
|
|
||
| let tree: TestRenderer.ReactTestRenderer | undefined; | ||
| await act(async () => { | ||
| tree = TestRenderer.create(React.createElement(ConversationsSidebar)); | ||
| }); | ||
|
|
||
| if (!tree) throw new Error("Component failed to render"); | ||
|
|
||
| const root = tree.root; | ||
|
|
||
| // Find the delete button | ||
| // It should have data-testid="conv-delete" | ||
| const deleteButton = root.findByProps({ "data-testid": "conv-delete" }); | ||
|
|
||
| // Assert accessibility label | ||
| expect(deleteButton.props["aria-label"]).toBe("Delete conversation"); | ||
|
|
||
| // Assert visibility on focus | ||
| expect(deleteButton.props.className).toContain("focus:opacity-100"); | ||
|
|
||
| // Assert icon is hidden from screen readers | ||
| // We expect a span inside with aria-hidden="true" | ||
| // Find span child | ||
| const span = deleteButton.findByType("span"); | ||
| expect(span.props["aria-hidden"]).toBe("true"); | ||
|
|
||
| // Check if the content is correct | ||
| // Depending on implementation, it might be children of span | ||
| expect(span.children).toContain("×"); | ||
| }); | ||
| }); |
💡 What: Improved the accessibility of the "delete conversation" button in the sidebar.
🎯 Why: The button was previously only visible on hover (opacity-0) and lacked an accessible label, making it invisible to keyboard users and screen readers.
♿ Accessibility:
aria-labelfor screen readers.focus:opacity-100so keyboard users can see the button when tabbing.PR created automatically by Jules for task 2585079205989504085 started by @Dexploarer