Skip to content

Commit caa3065

Browse files
fix styles not working on table and container based comps
1 parent 76c8e81 commit caa3065

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

client/packages/lowcoder/src/comps/comps/pageLayoutComp/pageLayoutComp.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { trans } from "i18n";
2929
import { ControlNode } from "lowcoder-design";
3030
import { StringControl } from "comps/controls/codeControl";
3131
import SliderControl from "@lowcoder-ee/comps/controls/sliderControl";
32+
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
3233

3334
const childrenMap = {
3435
header: SimpleContainerComp,
@@ -65,6 +66,7 @@ const childrenMap = {
6566
// Compatible with old style data 2022-8-15
6667
const layoutBaseComp = migrateOldData(
6768
new MultiCompBuilder(childrenMap, (props, dispatch) => {
69+
useMergeCompStyles(props, dispatch);
6870
return { ...props, dispatch };
6971
}).build(),
7072
fixOldStyleData

client/packages/lowcoder/src/comps/comps/tableComp/tableCompView.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { darkenColor, isDarkColor, ScrollBar } from "lowcoder-design";
3333
import React, { Children, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
3434
import { Resizable } from "react-resizable";
3535
import styled, { css } from "styled-components";
36-
import { useUserViewMode } from "util/hooks";
36+
import { useMergeCompStyles, useUserViewMode } from "util/hooks";
3737
import { TableImplComp } from "./tableComp";
3838
import { useResizeDetector } from "react-resize-detector";
3939
import { SlotConfigContext } from "comps/controls/slotControl";
@@ -903,7 +903,6 @@ export function TableCompView(props: {
903903
updateEmptyRows();
904904
}, [updateEmptyRows]);
905905

906-
907906
const pageDataInfo = useMemo(() => {
908907
// Data pagination
909908
let pagedData = data;
@@ -928,6 +927,11 @@ export function TableCompView(props: {
928927

929928
const childrenProps = childrenToProps(comp.children);
930929

930+
useMergeCompStyles(
931+
childrenProps as Record<string, any>,
932+
comp.dispatch
933+
);
934+
931935
const handleChangeEvent = useCallback(
932936
(eventName: TableEventOptionValues) => {
933937
if (eventName === "saveChanges" && !compChildren.onEvent.isBind(eventName)) {

client/packages/lowcoder/src/comps/comps/triContainerComp/triContainerComp.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { ContainerBodyChildComp } from "./containerBodyChildComp";
2828
import { trans } from "i18n";
2929
import { ControlNode } from "lowcoder-design";
3030
import SliderControl from "@lowcoder-ee/comps/controls/sliderControl";
31+
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
3132

3233
const childrenMap = {
3334
header: SimpleContainerComp,
@@ -53,6 +54,7 @@ const childrenMap = {
5354
// Compatible with old style data 2022-8-15
5455
const TriContainerBaseComp = migrateOldData(
5556
new MultiCompBuilder(childrenMap, (props, dispatch) => {
57+
useMergeCompStyles(props, dispatch);
5658
return { ...props, dispatch };
5759
}).build(),
5860
fixOldStyleData

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,10 @@ function calcColors<ColorMap extends Record<string, string>>(
673673
themeWithDefault.textDark,
674674
themeWithDefault.textLight
675675
);
676-
} else if (config?.depType === DEP_TYPE.SELF && config.depTheme === "canvas" && bgColor) {
677-
res[name] = bgColor;
678676
} else if ((config?.depType || config?.depName) && compTheme?.[name]) {
679677
res[name] = compTheme[name];
678+
} else if (config?.depType === DEP_TYPE.SELF && config.depTheme === "canvas" && bgColor) {
679+
res[name] = bgColor;
680680
} else {
681681
const rest = [];
682682
config.depName && rest.push(res[config.depName]);
@@ -900,7 +900,7 @@ export function styleControl<T extends readonly SingleColorConfig[]>(
900900

901901
const appSettingsComp = editorState?.getAppSettingsComp();
902902
const preventAppStylesOverwriting = appSettingsComp?.getView()?.preventAppStylesOverwriting;
903-
const { appliedThemeId, preventStyleOverwriting } = comp?.comp?.container || comp?.comp || {};
903+
const { appliedThemeId, preventStyleOverwriting } = (comp?.comp || {});
904904
const appTheme = isPreviewTheme || isDefaultTheme || (!preventStyleOverwriting && !preventAppStylesOverwriting)
905905
? theme?.theme
906906
: defaultTheme;

0 commit comments

Comments
 (0)