Skip to content

Commit 27a3eeb

Browse files
reduce div wrappers around UICompBuilder
1 parent 447ecf3 commit 27a3eeb

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

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

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,6 @@ export function HidableView(props: {
5454
}
5555
}
5656

57-
export function ExtendedComponentView(props: {
58-
children: JSX.Element | React.ReactNode;
59-
className: string;
60-
dataTestId: string;
61-
}) {
62-
if (!props.className && !props.dataTestId) {
63-
return <>{props.children}</>;
64-
}
65-
66-
return (
67-
<div className={props.className} data-testid={props.dataTestId} style={{ width: "100%", height: "100%", margin: "0px", padding: "0px" }}>
68-
{props.children}
69-
</div>
70-
);
71-
}
72-
7357
export function ExtendedPropertyView<
7458
ChildrenCompMap extends Record<string, Comp<unknown>>,
7559
>(props: {
@@ -196,7 +180,13 @@ export class UICompBuilder<
196180
}
197181

198182
override getView(): ViewReturn {
199-
return (<div ref={this.ref} style={{height:"100%",width:"100%",margin:0,padding:0}}><UIView comp={this} viewFn={builder.viewFn} /></div>);
183+
return (
184+
<UIView
185+
innerRef={this.ref}
186+
comp={this}
187+
viewFn={builder.viewFn}
188+
/>
189+
);
200190
}
201191

202192
override getPropertyView(): ReactNode {
@@ -223,7 +213,11 @@ export const DisabledContext = React.createContext<boolean>(false);
223213
/**
224214
* Guaranteed to be in a react component, so that react hooks can be used internally
225215
*/
226-
function UIView(props: { comp: any; viewFn: any }) {
216+
function UIView(props: {
217+
innerRef: React.RefObject<HTMLDivElement>;
218+
comp: any;
219+
viewFn: any;
220+
}) {
227221
const comp = props.comp;
228222

229223
const childrenProps = childrenToProps(comp.children);
@@ -243,13 +237,22 @@ function UIView(props: { comp: any; viewFn: any }) {
243237
//END ADD BY FRED
244238

245239
return (
246-
<ExtendedComponentView
240+
<div
241+
ref={props.innerRef}
247242
className={childrenProps.className as string}
248-
dataTestId={childrenProps.dataTestId as string}
249-
>
243+
data-testid={childrenProps.dataTestId as string}
244+
style={{
245+
width: "100%",
246+
height: "100%",
247+
margin: "0px",
248+
padding: "0px",
249+
}}>
250250
<HidableView hidden={childrenProps.hidden as boolean}>
251-
{props.viewFn(childrenProps, comp.dispatch)}
251+
{props.viewFn(
252+
childrenProps,
253+
comp.dispatch
254+
)}
252255
</HidableView>
253-
</ExtendedComponentView>
256+
</div>
254257
);
255258
}

0 commit comments

Comments
 (0)