@@ -346,6 +346,40 @@ const XFlow: FC<FlowProps> = memo(props => {
346346 const strokeWidth = globalConfig ?. edge ?. strokeWidth ?? 1.5 ;
347347 const panelonClose = globalConfig ?. nodePanel ?. onClose ;
348348
349+ const handleClosePanel = useMemoizedFn ( async ( ) => {
350+ // 面板关闭校验表单
351+ const result = await nodeEditorRef ?. current ?. validateForm ( ) ;
352+ if ( ! result ) {
353+ return ;
354+ }
355+ setOpenPanel ( false ) ;
356+ workflowContainerRef . current ?. focus ( ) ;
357+
358+ // 如果日志面板关闭
359+ if ( ! isTruthy ( activeNode ?. _status ) || ! openLogPanel ) {
360+ setActiveNode ( null ) ;
361+ }
362+ if ( isFunction ( panelonClose ) ) {
363+ panelonClose ( activeNode ?. id ) ;
364+ }
365+ } ) ;
366+
367+ const handleCloseLogPanel = useMemoizedFn ( ( ) => {
368+ setOpenLogPanel ( false ) ;
369+ ! openPanel && setActiveNode ( null ) ;
370+ workflowContainerRef . current ?. focus ( ) ;
371+ } ) ;
372+
373+ // 点击空白处关闭抽屉
374+ const handlePaneClick = useMemoizedFn ( ( ) => {
375+ if ( openPanel && activeNode ) {
376+ handleClosePanel ( ) ;
377+ }
378+ if ( openLogPanel && activeNode ) {
379+ handleCloseLogPanel ( ) ;
380+ }
381+ } ) ;
382+
349383 return (
350384 < div
351385 id = "xflow-container"
@@ -440,6 +474,7 @@ const XFlow: FC<FlowProps> = memo(props => {
440474 onEdgeClick = { ( event , edge ) => {
441475 onEdgeClick && onEdgeClick ( event , edge ) ;
442476 } }
477+ onPaneClick = { handlePaneClick }
443478 >
444479 < CandidateNode />
445480 < Operator addNode = { handleAddNode } xflowRef = { workflowContainerRef } />
@@ -453,23 +488,7 @@ const XFlow: FC<FlowProps> = memo(props => {
453488 < PanelContainer
454489 id = { activeNode ?. id }
455490 nodeType = { activeNode ?. _nodeType }
456- onClose = { async ( ) => {
457- // 面板关闭校验表单
458- const result = await nodeEditorRef ?. current ?. validateForm ( ) ;
459- if ( ! result ) {
460- return ;
461- }
462- setOpenPanel ( false ) ;
463- workflowContainerRef . current ?. focus ( ) ;
464-
465- // 如果日志面板关闭
466- if ( ! isTruthy ( activeNode ?. _status ) || ! openLogPanel ) {
467- setActiveNode ( null ) ;
468- }
469- if ( isFunction ( panelonClose ) ) {
470- panelonClose ( activeNode ?. id ) ;
471- }
472- } }
491+ onClose = { handleClosePanel }
473492 node = { activeNode }
474493 data = { activeNode ?. values }
475494 openLogPanel = { openLogPanel }
@@ -483,11 +502,7 @@ const XFlow: FC<FlowProps> = memo(props => {
483502 < PanelStatusLogContainer
484503 id = { activeNode ?. id }
485504 nodeType = { activeNode ?. _nodeType }
486- onClose = { ( ) => {
487- setOpenLogPanel ( false ) ;
488- ! openPanel && setActiveNode ( null ) ;
489- workflowContainerRef . current ?. focus ( ) ;
490- } }
505+ onClose = { handleCloseLogPanel }
491506 data = { activeNode ?. values }
492507 >
493508 { NodeLogWrap }
0 commit comments