-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: auto-approve checkbox now expands menu when no options selected #7549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -185,7 +185,14 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => { | |||||||||||||||||||||||||||
| cursor: "pointer", | ||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||
| onClick={toggleExpanded}> | ||||||||||||||||||||||||||||
| <div onClick={(e) => e.stopPropagation()}> | ||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||
| onClick={(e) => { | ||||||||||||||||||||||||||||
| e.stopPropagation() | ||||||||||||||||||||||||||||
| // If no options are selected, clicking the checkbox area should expand the menu | ||||||||||||||||||||||||||||
| if (!hasEnabledOptions) { | ||||||||||||||||||||||||||||
| setIsExpanded(true) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| }}> | ||||||||||||||||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The nested click handlers with stopPropagation() create a somewhat complex event flow. Could we simplify this by having a single click handler that checks both conditions? Something like:
Suggested change
|
||||||||||||||||||||||||||||
| <StandardTooltip | ||||||||||||||||||||||||||||
| content={!hasEnabledOptions ? t("chat:autoApprove.selectOptionsFirst") : undefined}> | ||||||||||||||||||||||||||||
| <VSCodeCheckbox | ||||||||||||||||||||||||||||
|
|
@@ -202,7 +209,7 @@ const AutoApproveMenu = ({ style }: AutoApproveMenuProps) => { | |||||||||||||||||||||||||||
| setAutoApprovalEnabled(newValue) | ||||||||||||||||||||||||||||
| vscode.postMessage({ type: "autoApprovalEnabled", bool: newValue }) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| // If no options enabled, do nothing | ||||||||||||||||||||||||||||
| // If no options enabled, the onClick handler above will expand the menu | ||||||||||||||||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment might be clearer if it mentioned this is the fallback behavior:
Suggested change
|
||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||
| </StandardTooltip> | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -115,7 +115,7 @@ describe("AutoApproveMenu", () => { | |||||||||||||
| expect(screen.getByText("Read-only operations")).toBeInTheDocument() | ||||||||||||||
| }) | ||||||||||||||
|
|
||||||||||||||
| it("should not allow toggling master checkbox when no options are selected", () => { | ||||||||||||||
| it("should expand menu when clicking checkbox area with no options selected", async () => { | ||||||||||||||
| ;(useExtensionState as ReturnType<typeof vi.fn>).mockReturnValue({ | ||||||||||||||
| ...defaultExtensionState, | ||||||||||||||
| autoApprovalEnabled: false, | ||||||||||||||
|
|
@@ -124,12 +124,18 @@ describe("AutoApproveMenu", () => { | |||||||||||||
|
|
||||||||||||||
| render(<AutoApproveMenu />) | ||||||||||||||
|
|
||||||||||||||
| // Click on the master checkbox | ||||||||||||||
| // Click on the checkbox container (since the checkbox itself is disabled) | ||||||||||||||
| const masterCheckbox = screen.getByRole("checkbox") | ||||||||||||||
| fireEvent.click(masterCheckbox) | ||||||||||||||
| const checkboxContainer = masterCheckbox.parentElement | ||||||||||||||
| fireEvent.click(checkboxContainer!) | ||||||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| // Should not send any message since no options are selected | ||||||||||||||
| expect(mockPostMessage).not.toHaveBeenCalled() | ||||||||||||||
|
|
||||||||||||||
| // But should expand the menu to show options | ||||||||||||||
| await waitFor(() => { | ||||||||||||||
| expect(screen.getByTestId("always-allow-readonly-toggle")).toBeInTheDocument() | ||||||||||||||
| }) | ||||||||||||||
| }) | ||||||||||||||
|
|
||||||||||||||
| it("should toggle master checkbox when options are selected", () => { | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested this with keyboard navigation? The click handler on the div wrapper could potentially interfere with keyboard accessibility or screen reader interactions. It might be worth verifying that the checkbox remains fully accessible.