mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-25 20:02:47 +00:00
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 <noreply@anthropic.com> Co-authored-by: Happy <yesreply@happy.engineering>
This commit is contained in:
parent
703ef2cd56
commit
ca3053f04d
|
|
@ -156,6 +156,25 @@ const SelectAppModal = ({
|
||||||
const selected = selectedList.some((app) => app.appId === item._id);
|
const selected = selectedList.some((app) => app.appId === item._id);
|
||||||
const isFolder = AppFolderTypeList.includes(item.type);
|
const isFolder = AppFolderTypeList.includes(item.type);
|
||||||
|
|
||||||
|
const handleItemClick = () => {
|
||||||
|
if (isFolder) {
|
||||||
|
setParentId(item._id);
|
||||||
|
} else if (selected) {
|
||||||
|
setSelectedList((state) => state.filter((app) => app.appId !== item._id));
|
||||||
|
} else {
|
||||||
|
setSelectedList((state) => [
|
||||||
|
...state,
|
||||||
|
{
|
||||||
|
appId: item._id,
|
||||||
|
toolName: item.name,
|
||||||
|
appName: item.name,
|
||||||
|
avatar: item.avatar,
|
||||||
|
description: item.intro
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HStack
|
<HStack
|
||||||
key={item._id}
|
key={item._id}
|
||||||
|
|
@ -166,27 +185,15 @@ const SelectAppModal = ({
|
||||||
_hover={{
|
_hover={{
|
||||||
bg: 'myGray.100'
|
bg: 'myGray.100'
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={handleItemClick}
|
||||||
if (isFolder) {
|
|
||||||
setParentId(item._id);
|
|
||||||
} else if (selected) {
|
|
||||||
setSelectedList((state) => state.filter((app) => app.appId !== item._id));
|
|
||||||
} else {
|
|
||||||
setSelectedList((state) => [
|
|
||||||
...state,
|
|
||||||
{
|
|
||||||
appId: item._id,
|
|
||||||
toolName: item.name,
|
|
||||||
appName: item.name,
|
|
||||||
avatar: item.avatar,
|
|
||||||
description: item.intro
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Flex alignItems={'center'} w={'1.25rem'}>
|
<Flex alignItems={'center'} w={'1.25rem'} onClick={(e) => e.stopPropagation()}>
|
||||||
{!isFolder && <Checkbox isChecked={selected} />}
|
{!isFolder && (
|
||||||
|
<Checkbox
|
||||||
|
isChecked={selected}
|
||||||
|
onChange={handleItemClick}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
<Avatar src={item.avatar} w="1.5rem" borderRadius={'sm'} />
|
<Avatar src={item.avatar} w="1.5rem" borderRadius={'sm'} />
|
||||||
<Box>{item.name}</Box>
|
<Box>{item.name}</Box>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue