@@ -47,7 +47,7 @@ const ExecuteCompTmpAction = (function() {
47
47
params : ParamsValueControl
48
48
} ;
49
49
return new MultiCompBuilder ( childrenMap , ( ) => {
50
- return ( ) => Promise . resolve ( undefined as unknown ) ;
50
+ return ( ) => undefined as ( React . RefObject < HTMLElement > | undefined ) ;
51
51
} )
52
52
. setPropertyViewFn ( ( ) => < > </ > )
53
53
. build ( ) ;
@@ -71,30 +71,19 @@ export function targetCompAction(params: ExecuteCompActionOptions) {
71
71
return `${ name } .${ method } ()` ;
72
72
}
73
73
}
74
-
75
- override getView ( ) {
76
- const name = this . children . name . getView ( ) ;
77
- if ( ! name ) {
78
- return ( ) => Promise . resolve ( ) ;
74
+
75
+ selectedComp : ( GridItemComp | HookComp | InstanceType < typeof TemporaryStateItemComp > ) | undefined ;
76
+ compList : ( GridItemComp | HookComp | InstanceType < typeof TemporaryStateItemComp > ) [ ] = [ ] ;
77
+
78
+ updateSelectedComp ( compName : string ) : void {
79
+ const compListItem = this . compList . find ( ( compItem ) => compItem . children . name . getView ( ) === compName ) ;
80
+ if ( compListItem ) {
81
+ this . selectedComp = compListItem ;
79
82
}
80
- return ( ) =>
81
- getPromiseAfterDispatch (
82
- this . dispatch ,
83
- routeByNameAction (
84
- name ,
85
- customAction < ExecuteAction > (
86
- {
87
- type : "execute" ,
88
- methodName : this . children . methodName . getView ( ) ,
89
- params : this . children . params . getView ( ) . map ( ( x ) => x . getView ( ) )
90
- } ,
91
- false
92
- )
93
- ) ,
94
- {
95
- notHandledError : trans ( "eventHandler.notHandledError" )
96
- }
97
- ) ;
83
+ }
84
+
85
+ override getView ( ) : ( ) => ( React . RefObject < HTMLElement > | undefined ) {
86
+ return ( ) => this . selectedComp ?. getRef ( ) ;
98
87
}
99
88
100
89
exposingNode ( ) {
@@ -105,32 +94,9 @@ export function targetCompAction(params: ExecuteCompActionOptions) {
105
94
return (
106
95
< EditorContext . Consumer >
107
96
{ ( editorState ) => {
108
- const compMethods : Record < string , Record < string , ParamsConfig > > = { } ;
109
97
const compList : ( GridItemComp | HookComp | InstanceType < typeof TemporaryStateItemComp > ) [ ] = compListGetter ( editorState ) ;
110
98
111
- compList . forEach ( ( item ) => {
112
- compMethods [ item . children . name . getView ( ) ] = mapValues (
113
- item . exposingInfo ( ) . methods ,
114
- ( v ) => v . params
115
- ) ;
116
- } ) ;
117
-
118
- function changeMethodAction ( compName : string , methodName : string ) {
119
- const currentMethods = compMethods [ compName ] ?? { } ;
120
- const params = currentMethods [ methodName ] ;
121
- return {
122
- name : compName ,
123
- methodName : methodName ,
124
- params : params ?. map ( ( p ) => ( {
125
- compType : p . type ,
126
- name : p . name
127
- } ) )
128
- } ;
129
- }
130
-
131
99
const name = this . children . name . getView ( ) ;
132
- const methods = compMethods [ name ] ?? { } ;
133
- const params = methods [ this . children . methodName . getView ( ) ] ;
134
100
return (
135
101
< >
136
102
< CompNameContext . Consumer >
@@ -139,21 +105,17 @@ export function targetCompAction(params: ExecuteCompActionOptions) {
139
105
showSearch = { true }
140
106
value = { name }
141
107
options = { compList
142
- . filter (
143
- ( item ) =>
144
- Object . keys ( compMethods [ item . children . name . getView ( ) ] ) . length > 0
145
- )
146
108
. filter ( ( item ) => item . children . name . getView ( ) !== compName )
147
109
. map ( ( item ) => ( {
148
110
label : item . children . name . getView ( ) ,
149
111
value : item . children . name . getView ( )
150
112
} ) ) }
151
113
label = { selectLabel }
152
- onChange = { ( value ) =>
153
- this . dispatchChangeValueAction (
154
- changeMethodAction ( value , Object . keys ( compMethods [ value ] ) [ 0 ] )
155
- )
156
- }
114
+ onChange = { ( value ) => {
115
+ console . log ( `the value is ${ value } ` ) ;
116
+ // After the value is changed, update `selectedComp`
117
+ this . updateSelectedComp ( value ) ;
118
+ } }
157
119
/>
158
120
) }
159
121
</ CompNameContext . Consumer >
0 commit comments