Skip to content

Commit 08690fc

Browse files
committed
fix: table compos editorMode status
1 parent a9502fe commit 08690fc

4 files changed

Lines changed: 16 additions & 24 deletions

File tree

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ import { RowColorComp, RowHeightComp, SortValue, TableChildrenView, TableInitCom
6262

6363
import { useContext, useState } from "react";
6464
import { EditorContext } from "comps/editorState";
65-
import { useEditorStore } from "comps/editorStore";
6665

6766
export class TableImplComp extends TableInitComp implements IContainer {
6867
private prevUnevaledValue?: string;
@@ -565,16 +564,7 @@ let TableTmpComp = withViewFn(TableImplComp, (comp) => {
565564
});
566565

567566

568-
const withEditorModeStatus = (Component:any) => (props:any) => {
569-
const editorModeStatus = useEditorStore((state) => state.editorModeStatus);
570-
const {ref, ...otherProps} = props;
571-
return <Component {...otherProps} editorModeStatus={editorModeStatus} />;
572-
};
573-
574-
// Use this HOC when defining TableTmpComp
575-
TableTmpComp = withPropertyViewFn(TableTmpComp, (comp) => withEditorModeStatus(compTablePropertyView)(comp));
576-
577-
// TableTmpComp = withPropertyViewFn(TableTmpComp, compTablePropertyView);
567+
TableTmpComp = withPropertyViewFn(TableTmpComp, compTablePropertyView);
578568

579569

580570

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { alignOptions } from "comps/controls/dropdownControl";
3535
import { ColumnTypeCompMap } from "comps/comps/tableComp/column/columnTypeComp";
3636
import Segmented from "antd/es/segmented";
3737
import { CheckboxChangeEvent } from "antd/es/checkbox";
38+
import { useEditorStore } from "comps/editorStore";
3839

3940
const InsertDiv = styled.div`
4041
display: flex;
@@ -496,8 +497,8 @@ function columnPropertyView<T extends MultiBaseComp<TableChildrenType>>(comp: T)
496497
];
497498
}
498499

499-
export function compTablePropertyView<T extends MultiBaseComp<TableChildrenType> & { editorModeStatus: string }>(comp: T) {
500-
const editorModeStatus = comp.editorModeStatus;
500+
function TablePropertyView<T extends MultiBaseComp<TableChildrenType>>({ comp }: { comp: T }) {
501+
const editorModeStatus = useEditorStore((state) => state.editorModeStatus);
501502
const dataLabel = trans("data");
502503

503504
return (
@@ -661,3 +662,7 @@ export function compTablePropertyView<T extends MultiBaseComp<TableChildrenType>
661662
</>
662663
);
663664
}
665+
666+
export function compTablePropertyView<T extends MultiBaseComp<TableChildrenType>>(comp: T) {
667+
return <TablePropertyView comp={comp} />;
668+
}

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import { RowColorComp, RowHeightComp, TableChildrenView, TableInitComp } from ".
4242

4343
import { useContext } from "react";
4444
import { EditorContext } from "comps/editorState";
45-
import { useEditorStore } from "comps/editorStore";
4645
import { tableMethodExposings } from "./methods/tableMethodExposings";
4746
import { buildSortedDataNode, buildFilteredDataNode, buildOriDisplayDataNode, buildColumnAggrNode } from "./nodes/dataNodes";
4847

@@ -242,14 +241,7 @@ let TableTmpComp = withViewFn(TableImplComp, (comp) => {
242241
);
243242
});
244243

245-
const withEditorModeStatus = (Component:any) => (props:any) => {
246-
const editorModeStatus = useEditorStore((state) => state.editorModeStatus);
247-
const {ref, ...otherProps} = props;
248-
return <Component {...otherProps} editorModeStatus={editorModeStatus} />;
249-
};
250-
251-
252-
TableTmpComp = withPropertyViewFn(TableTmpComp, (comp) => withEditorModeStatus(compTablePropertyView)(comp));
244+
TableTmpComp = withPropertyViewFn(TableTmpComp, compTablePropertyView);
253245

254246
TableTmpComp = withDispatchHook(TableTmpComp, (dispatch) => (action) => {
255247
if (!dispatch) {

client/packages/lowcoder/src/comps/comps/tableLiteComp/tablePropertyView.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { alignOptions } from "comps/controls/dropdownControl";
3535
import { ColumnTypeCompMap } from "./column/columnTypeComp";
3636
import Segmented from "antd/es/segmented";
3737
import { CheckboxChangeEvent } from "antd/es/checkbox";
38+
import { useEditorStore } from "comps/editorStore";
3839

3940
const InsertDiv = styled.div`
4041
display: flex;
@@ -485,8 +486,8 @@ function columnPropertyView<T extends MultiBaseComp<TableChildrenType>>(comp: T)
485486
];
486487
}
487488

488-
export function compTablePropertyView<T extends MultiBaseComp<TableChildrenType> & { editorModeStatus: string }>(comp: T) {
489-
const editorModeStatus = comp.editorModeStatus;
489+
function TablePropertyView<T extends MultiBaseComp<TableChildrenType>>({ comp }: { comp: T }) {
490+
const editorModeStatus = useEditorStore((state) => state.editorModeStatus);
490491
const dataLabel = trans("data");
491492

492493
return (
@@ -635,3 +636,7 @@ export function compTablePropertyView<T extends MultiBaseComp<TableChildrenType>
635636
</>
636637
);
637638
}
639+
640+
export function compTablePropertyView<T extends MultiBaseComp<TableChildrenType>>(comp: T) {
641+
return <TablePropertyView comp={comp} />;
642+
}

0 commit comments

Comments
 (0)