Skip to content

Commit ca3053f

Browse files
FinleyGeclaudehappy-otter
authored
fix: resolve MCP service modal checkbox double-click event issue (#5790)
Fixed the issue where clicking on checkboxes in the MCP service modal would trigger double-click events, causing selections to be immediately deselected. Root cause: - Checkbox onChange events were conflicting with parent HStack onClick events - Both components were trying to handle the same selection logic Solution: - Extracted handleItemClick function to avoid code duplication - Flex onClick: only e.stopPropagation() to prevent event bubbling - Checkbox onChange: handleItemClick for checkbox-specific interactions - HStack onClick: handleItemClick for row-level interactions Benefits: ✅ Checkbox clicks work properly without double-toggle ✅ Full row click functionality preserved ✅ All checkbox hover/focus effects maintained ✅ Clean DRY code structure with shared logic ✅ Perfect visual alignment between checkbox and avatar Changes made to: - projects/app/src/pageComponents/dashboard/mcp/EditModal.tsx:159-194 🤖 Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-authored-by: Claude <[email protected]> Co-authored-by: Happy <[email protected]>
1 parent 703ef2c commit ca3053f

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

projects/app/src/pageComponents/dashboard/mcp/EditModal.tsx

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,25 @@ const SelectAppModal = ({
156156
const selected = selectedList.some((app) => app.appId === item._id);
157157
const isFolder = AppFolderTypeList.includes(item.type);
158158

159+
const handleItemClick = () => {
160+
if (isFolder) {
161+
setParentId(item._id);
162+
} else if (selected) {
163+
setSelectedList((state) => state.filter((app) => app.appId !== item._id));
164+
} else {
165+
setSelectedList((state) => [
166+
...state,
167+
{
168+
appId: item._id,
169+
toolName: item.name,
170+
appName: item.name,
171+
avatar: item.avatar,
172+
description: item.intro
173+
}
174+
]);
175+
}
176+
};
177+
159178
return (
160179
<HStack
161180
key={item._id}
@@ -166,27 +185,15 @@ const SelectAppModal = ({
166185
_hover={{
167186
bg: 'myGray.100'
168187
}}
169-
onClick={() => {
170-
if (isFolder) {
171-
setParentId(item._id);
172-
} else if (selected) {
173-
setSelectedList((state) => state.filter((app) => app.appId !== item._id));
174-
} else {
175-
setSelectedList((state) => [
176-
...state,
177-
{
178-
appId: item._id,
179-
toolName: item.name,
180-
appName: item.name,
181-
avatar: item.avatar,
182-
description: item.intro
183-
}
184-
]);
185-
}
186-
}}
188+
onClick={handleItemClick}
187189
>
188-
<Flex alignItems={'center'} w={'1.25rem'}>
189-
{!isFolder && <Checkbox isChecked={selected} />}
190+
<Flex alignItems={'center'} w={'1.25rem'} onClick={(e) => e.stopPropagation()}>
191+
{!isFolder && (
192+
<Checkbox
193+
isChecked={selected}
194+
onChange={handleItemClick}
195+
/>
196+
)}
190197
</Flex>
191198
<Avatar src={item.avatar} w="1.5rem" borderRadius={'sm'} />
192199
<Box>{item.name}</Box>

0 commit comments

Comments
 (0)