Skip to content

[FIX] GlobalCSS styles for Modals/Drawers #1588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 21, 2025
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ application-dev-localhost.yaml
server/api-service/lowcoder-server/src/main/resources/application-local-dev.yaml
translations/locales/node_modules/
server/api-service/lowcoder-server/src/main/resources/application-local-dev-ee.yaml
node_modules
2 changes: 1 addition & 1 deletion client/packages/lowcoder-core/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3331,7 +3331,7 @@ function styleNamespace(id) {
function evalStyle(id, css, globalStyle) {
var _a;
var styleId = styleNamespace(id);
var prefixId = globalStyle ? id : "#".concat(id);
var prefixId = globalStyle ? id : ".".concat(id);
var compiledCSS = "";
css.forEach(function (i) {
if (!i.trim()) {
Expand Down
2 changes: 1 addition & 1 deletion client/packages/lowcoder-core/src/eval/utils/evalStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function styleNamespace(id: string) {

export function evalStyle(id: string, css: string[], globalStyle?: boolean) {
const styleId = styleNamespace(id);
const prefixId = globalStyle ? id : `#${id}`
const prefixId = globalStyle ? id : `.${id}`;
let compiledCSS = "";
css.forEach((i) => {
if (!i.trim()) {
Expand Down
7 changes: 6 additions & 1 deletion client/packages/lowcoder/src/comps/comps/rootComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { useUserViewMode } from "util/hooks";
import React from "react";
import { isEqual } from "lodash";
import {LoadingBarHideTrigger} from "@lowcoder-ee/util/hideLoading";
import clsx from "clsx";
const EditorView = lazy(
() => import("pages/editor/editorView"),
);
Expand Down Expand Up @@ -130,7 +131,11 @@ const RootView = React.memo((props: RootViewProps) => {
}

return (
<div {...divProps} style={{height: '100%'}}>
<div {...divProps}
className={clsx(
divProps.id,
)}
style={{height: '100%'}}>
<PropertySectionContext.Provider value={propertySectionContextValue}>
<ThemeContext.Provider value={themeContextValue}>
<EditorContext.Provider value={editorState}>
Expand Down
5 changes: 4 additions & 1 deletion client/packages/lowcoder/src/comps/hooks/drawerComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { isNumeric } from "util/stringUtils";
import { NameConfig, withExposingConfigs } from "../generators/withExposing";
import { title } from "process";
import { SliderControl } from "../controls/sliderControl";
import clsx from "clsx";
import { useApplicationId } from "util/hooks";

const EventOptions = [closeEvent] as const;

Expand Down Expand Up @@ -119,6 +121,7 @@ let TmpDrawerComp = (function () {
const isTopBom = ["top", "bottom"].includes(props.placement);
const { items, ...otherContainerProps } = props.container;
const userViewMode = useUserViewMode();
const appID = useApplicationId();
const resizable = !userViewMode && (!isTopBom || !props.autoHeight);
const onResizeStop = useCallback(
(
Expand Down Expand Up @@ -172,7 +175,7 @@ let TmpDrawerComp = (function () {
zIndex={Layers.drawer}
maskClosable={props.maskClosable}
mask={props.showMask}
className={props.className as string}
className={clsx(`app-${appID}`, props.className)}
data-testid={props.dataTestId as string}
>
{props.toggleClose && (
Expand Down
5 changes: 4 additions & 1 deletion client/packages/lowcoder/src/comps/hooks/modalComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { BoolControl } from "comps/controls/boolControl";
import { withDefault } from "comps/generators";
import { SliderControl } from "../controls/sliderControl";
import { getBackgroundStyle } from "@lowcoder-ee/util/styleUtils";
import clsx from "clsx";
import { useApplicationId } from "util/hooks";

const EventOptions = [
{ label: trans("modalComp.open"), value: "open", description: trans("modalComp.openDesc") },
Expand Down Expand Up @@ -113,6 +115,7 @@ let TmpModalComp = (function () {
},
(props, dispatch) => {
const userViewMode = useUserViewMode();
const appID = useApplicationId();
const bodyStyle: CSSProperties = { padding: 0 };
const width = transToPxSize(props.width || DEFAULT_WIDTH);
let height = undefined;
Expand Down Expand Up @@ -177,7 +180,7 @@ let TmpModalComp = (function () {
zIndex={Layers.modal}
modalRender={(node) => <ModalStyled $style={props.style} $modalScrollbar={props.modalScrollbar}>{node}</ModalStyled>}
mask={props.showMask}
className={props.className as string}
className={clsx(`app-${appID}`, props.className)}
data-testid={props.dataTestId as string}
>
<InnerGrid
Expand Down
Loading