fix: resize workflow canvas cause incorrect comment position

This commit is contained in:
hjlarry
2025-11-05 14:08:21 +08:00
parent ee3ded0fc2
commit 2f60288d86
5 changed files with 50 additions and 13 deletions

View File

@ -107,7 +107,10 @@ export const useWorkflowComment = () => {
try {
// Convert screen position to flow position when submitting
const { screenToFlowPosition } = reactflow
const flowPosition = screenToFlowPosition({ x: pendingComment.x, y: pendingComment.y })
const flowPosition = screenToFlowPosition({
x: pendingComment.pageX,
y: pendingComment.pageY,
})
const newComment = await createWorkflowComment(appId, {
position_x: flowPosition.x,
@ -452,10 +455,15 @@ export const useWorkflowComment = () => {
activeCommentIdRef.current = null
}, [setActiveComment, setActiveCommentId, setActiveCommentLoading])
const handleCreateComment = useCallback((mousePosition: { elementX: number; elementY: number }) => {
const handleCreateComment = useCallback((mousePosition: {
pageX: number
pageY: number
elementX: number
elementY: number
}) => {
if (controlMode === ControlMode.Comment) {
console.log('Setting pending comment at screen position:', mousePosition)
setPendingComment({ x: mousePosition.elementX, y: mousePosition.elementY })
setPendingComment(mousePosition)
}
else {
console.log('Control mode is not Comment:', controlMode)