Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9efdf32

Browse files
fix theme styling issue with active/inactive preventOverwritingStyles flag
1 parent045141c commit9efdf32

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

‎client/packages/lowcoder/src/comps/controls/styleControl.tsx‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -910,10 +910,6 @@ export function styleControl<T extends readonly SingleColorConfig[]>(
910910
...defaultTheme.components?.[compType]?.[styleKey]asunknownasRecord<string,string>,
911911
...(omit(theme?.theme,'components','chart')),
912912
...theme?.theme?.components?.[compType]?.[styleKey]asunknownasRecord<string,string>,
913-
// ...(
914-
// theme?.theme?.components?.[compType]?.[styleKey]
915-
// // || defaultTheme.components?.[compType]?.[styleKey]
916-
// ) as unknown as Record<string, string>
917913
}
918914
:defaultTheme.components?.[compType]?.[styleKey];
919915
conststyleProps=(!comp&&!compType)||preventStyleOverwriting||preventAppStylesOverwriting||appliedThemeId===themeId

‎client/packages/lowcoder/src/comps/generators/uiCompBuilder.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ const UIView = React.memo((props: {
290290
}
291291

292292
useMergeCompStyles(
293-
childrenJsonPropsasRecord<string,any>,
293+
childrenPropsasRecord<string,any>,
294294
comp.dispatch
295295
);
296296

‎client/packages/lowcoder/src/comps/utils/themeUtil.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ export function setInitialCompStyles({
3838
constactions:Record<string,any>={
3939
appliedThemeId:changeValueAction(themeId||'',true),
4040
};
41+
4142
styleKeys.forEach(styleKey=>{
4243
actions[styleKey]=changeValueAction({
4344
...(compTheme?.[styleKey]asobject||{}),
44-
//...styleProps[styleKey],
45+
...styleProps[styleKey],
4546
},true);
4647
})
4748

‎client/packages/lowcoder/src/util/hooks.ts‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AppPathParams } from "constants/applicationConstants";
22
importReact,{
33
Dispatch,
44
SetStateAction,
5+
useCallback,
56
useContext,
67
useEffect,
78
useMemo,
@@ -179,28 +180,49 @@ export function useMergeCompStyles(
179180
constthemeId=theme?.themeId;
180181
constappSettingsComp=editorState?.getAppSettingsComp();
181182
constpreventAppStylesOverwriting=appSettingsComp?.getView()?.preventAppStylesOverwriting;
182-
const{ preventStyleOverwriting}=props;
183+
const{ preventStyleOverwriting, appliedThemeId}=props;
183184

184185
conststyleKeys=Object.keys(props).filter(key=>key.toLowerCase().endsWith('style'||'styles'));
185186
conststyleProps:Record<string,any>={};
186187
styleKeys.forEach((key:string)=>{
187188
styleProps[key]=(propsasany)[key];
188189
});
189190

191+
constmergeStyles=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+
190208
useEffect(()=>{
191-
if(preventAppStylesOverwriting||preventStyleOverwriting)return;
192-
setInitialCompStyles({
209+
if(
210+
preventAppStylesOverwriting
211+
||preventStyleOverwriting
212+
||themeId===appliedThemeId
213+
)return;
214+
mergeStyles({
193215
dispatch,
194216
compTheme,
195217
styleProps,
196218
themeId,
197-
});
219+
})
198220
},[
199221
themeId,
200222
JSON.stringify(styleProps),
201223
JSON.stringify(compTheme),
202-
setInitialCompStyles,
224+
mergeStyles,
203225
preventAppStylesOverwriting,
204226
preventStyleOverwriting,
205227
]);
206-
}
228+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp