File tree Expand file tree Collapse file tree 4 files changed +31
-12
lines changed
client/packages/lowcoder/src Expand file tree Collapse file tree 4 files changed +31
-12
lines changed Original file line number Diff line number Diff line change @@ -910,10 +910,6 @@ export function styleControl<T extends readonly SingleColorConfig[]>(
910
910
...defaultTheme . components ?. [ compType ] ?. [ styleKey ] as unknown as Record < string , string > ,
911
911
...( omit ( theme ?. theme , 'components' , 'chart' ) ) ,
912
912
...theme ?. theme ?. components ?. [ compType ] ?. [ styleKey ] as unknown as Record < string , string > ,
913
- // ...(
914
- // theme?.theme?.components?.[compType]?.[styleKey]
915
- // // || defaultTheme.components?.[compType]?.[styleKey]
916
- // ) as unknown as Record<string, string>
917
913
}
918
914
: defaultTheme . components ?. [ compType ] ?. [ styleKey ] ;
919
915
const styleProps = ( ! comp && ! compType ) || preventStyleOverwriting || preventAppStylesOverwriting || appliedThemeId === themeId
Original file line number Diff line number Diff line change @@ -290,7 +290,7 @@ const UIView = React.memo((props: {
290
290
}
291
291
292
292
useMergeCompStyles (
293
- childrenJsonProps as Record < string , any > ,
293
+ childrenProps as Record < string , any > ,
294
294
comp . dispatch
295
295
) ;
296
296
Original file line number Diff line number Diff line change @@ -38,10 +38,11 @@ export function setInitialCompStyles({
38
38
const actions : Record < string , any > = {
39
39
appliedThemeId : changeValueAction ( themeId || '' , true ) ,
40
40
} ;
41
+
41
42
styleKeys . forEach ( styleKey => {
42
43
actions [ styleKey ] = changeValueAction ( {
43
44
...( compTheme ?. [ styleKey ] as object || { } ) ,
44
- // ...styleProps[styleKey],
45
+ ...styleProps [ styleKey ] ,
45
46
} , true ) ;
46
47
} )
47
48
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { AppPathParams } from "constants/applicationConstants";
2
2
import React , {
3
3
Dispatch ,
4
4
SetStateAction ,
5
+ useCallback ,
5
6
useContext ,
6
7
useEffect ,
7
8
useMemo ,
@@ -179,28 +180,49 @@ export function useMergeCompStyles(
179
180
const themeId = theme ?. themeId ;
180
181
const appSettingsComp = editorState ?. getAppSettingsComp ( ) ;
181
182
const preventAppStylesOverwriting = appSettingsComp ?. getView ( ) ?. preventAppStylesOverwriting ;
182
- const { preventStyleOverwriting } = props ;
183
+ const { preventStyleOverwriting, appliedThemeId } = props ;
183
184
184
185
const styleKeys = Object . keys ( props ) . filter ( key => key . toLowerCase ( ) . endsWith ( 'style' || 'styles' ) ) ;
185
186
const styleProps : Record < string , any > = { } ;
186
187
styleKeys . forEach ( ( key : string ) => {
187
188
styleProps [ key ] = ( props as any ) [ key ] ;
188
189
} ) ;
189
190
191
+ const mergeStyles = useCallback (
192
+ ( {
193
+ dispatch,
194
+ compTheme,
195
+ styleProps,
196
+ themeId
197
+ } : any ) => {
198
+ setInitialCompStyles ( {
199
+ dispatch,
200
+ compTheme,
201
+ styleProps,
202
+ themeId,
203
+ } )
204
+ } ,
205
+ [ ]
206
+ ) ;
207
+
190
208
useEffect ( ( ) => {
191
- if ( preventAppStylesOverwriting || preventStyleOverwriting ) return ;
192
- setInitialCompStyles ( {
209
+ if (
210
+ preventAppStylesOverwriting
211
+ || preventStyleOverwriting
212
+ || themeId === appliedThemeId
213
+ ) return ;
214
+ mergeStyles ( {
193
215
dispatch,
194
216
compTheme,
195
217
styleProps,
196
218
themeId,
197
- } ) ;
219
+ } )
198
220
} , [
199
221
themeId ,
200
222
JSON . stringify ( styleProps ) ,
201
223
JSON . stringify ( compTheme ) ,
202
- setInitialCompStyles ,
224
+ mergeStyles ,
203
225
preventAppStylesOverwriting ,
204
226
preventStyleOverwriting ,
205
227
] ) ;
206
- }
228
+ }
You can’t perform that action at this time.
0 commit comments