File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
packages/x-flow/src/components/PanelContainer Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
52
52
widgets,
53
53
openColorfulMode
54
54
} : any = useContext ( ConfigContext ) ;
55
+
55
56
const nodeSetting = settingMap [ nodeType ] || { } ;
56
57
const { nodes, setNodes } = useStore (
57
58
( state : any ) => ( {
@@ -60,6 +61,14 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
60
61
} ) ,
61
62
shallow
62
63
) ;
64
+ const activeNode = useMemo ( ( ) => {
65
+ const node = nodes . find ( ( r ) => r . id === id )
66
+ if ( node ) {
67
+ return node
68
+ } else {
69
+ return { }
70
+ }
71
+ } , [ nodes ] )
63
72
const isDisabled = disabled ; // 目前没用
64
73
const [ descVal , setDescVal ] = useState ( data ?. desc ) ;
65
74
const [ titleVal , setTitleVal ] = useState ( data ?. title || nodeSetting ?. title ) ;
@@ -91,9 +100,9 @@ const Panel: FC<IPanelProps> = (props: IPanelProps) => {
91
100
} , 100 ) ;
92
101
93
102
useEffect ( ( ) => {
94
- setDescVal ( data ?. desc ) ;
95
- setTitleVal ( data ?. title || nodeSetting ?. title ) ;
96
- } , [ safeJsonStringify ( data ) , id ] ) ;
103
+ setDescVal ( activeNode . data ?. desc ) ;
104
+ setTitleVal ( activeNode . data ?. title || nodeSetting ?. title ) ;
105
+ } , [ id , activeNode . data ?. desc , activeNode . data ?. title ] ) ;
97
106
98
107
const Icon = useMemo ( ( ) => createIconFont ( iconFontUrl ) , [ iconFontUrl ] ) ;
99
108
You can’t perform that action at this time.
0 commit comments