fix(ui): use explicit type="button" on ToolsSection buttons#1852
Open
kimsehwan96 wants to merge 3 commits into
Open
fix(ui): use explicit type="button" on ToolsSection buttons#1852kimsehwan96 wants to merge 3 commits into
kimsehwan96 wants to merge 3 commits into
Conversation
Buttons inside ToolsSection had no explicit type. When rendered inside the <form> on /agents/new they fell back to HTML's submit default, so clicking 'Add Tools & Agents' or a remove (X) button ran handleSaveAgent and navigated to /agents (creating a half-configured Agent on success). Signed-off-by: kimsehwan96 <sktpghks138@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes UI bug #1851 where clicking “Add Tools & Agents” (and related icon buttons) inside the agent form unintentionally submits the surrounding <form> by ensuring the relevant buttons explicitly use type="button".
Changes:
- Add
type="button"to all four<Button>elements inToolsSection.tsxto prevent implicit form submission. - Add a Jest/RTL regression test suite to ensure key ToolsSection interactions do not trigger form submit.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ui/src/components/create/ToolsSection.tsx | Sets explicit type="button" on ToolsSection buttons to avoid unintended form submission. |
| ui/src/components/create/tests/ToolsSection.test.tsx | Adds regression tests verifying ToolsSection buttons don’t submit a surrounding <form>. |
Comments suppressed due to low confidence (1)
ui/src/components/create/ToolsSection.tsx:195
- The icon-only remove (X) button has no accessible name. Add an
aria-label(and consider setting the<X />icon toaria-hidden) so screen readers can announce it and tests can target it reliably. This matches existing UI patterns (e.g.FragmentEntriesEditorusesaria-label="Remove fragment").
<Button
type="button"
variant="ghost"
size="sm"
className="h-8 w-8 shrink-0 p-0"
onClick={() => handleRemoveTool(parentToolIdentifier, mcpToolName)}
disabled={isSubmitting}
>
<X className="h-4 w-4" />
</Button>
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| expect(onSubmit).not.toHaveBeenCalled(); | ||
| expect(setSelectedTools).toHaveBeenCalledTimes(1); | ||
| }); |
Match aria-label + aria-hidden patterns used elsewhere. Target remove buttons by accessible name in tests. Add a regression case for the MCP-tool remove path. Signed-off-by: kimsehwan96 <sktpghks138@gmail.com>
Signed-off-by: kimsehwan96 <sktpghks138@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1851
AS-IS
2026-05-12.4.45.36.mov
TO-BE
2026-05-12.4.43.58.mov
Changes
Explicit
type="button"on all 4<Button>elements inToolsSection.tsxTests
Added
ui/src/components/create/__tests__/ToolsSection.test.tsx