Skip to content

Commit 18e49ca

Browse files
fix: replace maxHeight with auto/fixed Height
1 parent fe1affe commit 18e49ca

File tree

6 files changed

+16
-18
lines changed

6 files changed

+16
-18
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ export class TableImplComp extends TableInitComp implements IContainer {
5858
readonly filterData: RecordType[] = [];
5959
readonly columnAggrData: ColumnsAggrData = {};
6060

61+
override autoHeight(): boolean {
62+
return this.children.autoHeight.getView();
63+
}
64+
6165
private getSlotContainer() {
6266
return this.children.expansion.children.slot.getSelectedComp().getComp().children.container;
6367
}

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ const TableWrapper = styled.div<{
158158
$rowStyle: TableRowStyleType;
159159
toolbarPosition: "above" | "below" | "close";
160160
}>`
161-
overflow: hidden;
161+
max-height: 100%;
162+
overflow-y: auto;
162163
background: white;
163164
border: 1px solid #d7d9e0;
164165
@@ -364,7 +365,7 @@ type CustomTableProps<RecordType> = Omit<TableProps<RecordType>, "components" |
364365
rowColorFn: RowColorViewType;
365366
columnsStyle: TableColumnStyleType;
366367
fixedHeader: boolean;
367-
maxHeight: string;
368+
height?: number;
368369
};
369370

370371
function TableCellView(props: {
@@ -538,7 +539,7 @@ function ResizeableTable<RecordType extends object>(props: CustomTableProps<Reco
538539
columns={columns}
539540
scroll={{
540541
x: COL_MIN_WIDTH * columns.length,
541-
y: props.fixedHeader ? props.maxHeight : undefined,
542+
y: props.fixedHeader && props.height ? `${props.height - 100}px` : undefined,
542543
}}
543544
></Table>
544545
);
@@ -552,10 +553,10 @@ export function TableCompView(props: {
552553
onDownload: (fileName: string) => void;
553554
}) {
554555
const editorState = useContext(EditorContext);
555-
const { width, ref } = useResizeDetector({
556+
const { width, height, ref } = useResizeDetector({
556557
refreshMode: "debounce",
557558
refreshRate: 600,
558-
handleHeight: false,
559+
handleHeight: true,
559560
});
560561
const viewMode = useUserViewMode();
561562
const compName = useContext(CompNameContext);
@@ -671,8 +672,8 @@ export function TableCompView(props: {
671672

672673
return (
673674
<BackgroundColorContext.Provider value={style.background}>
675+
<div ref={ref} style={{height: '100%'}}>
674676
<TableWrapper
675-
ref={ref}
676677
$style={style}
677678
$rowStyle={rowStyle}
678679
toolbarPosition={toolbar.position}
@@ -697,13 +698,13 @@ export function TableCompView(props: {
697698
}}
698699
showHeader={!compChildren.hideHeader.getView()}
699700
fixedHeader={compChildren.fixedHeader.getView()}
700-
maxHeight={compChildren.maxHeight.getView()}
701701
columns={antdColumns}
702702
columnsStyle={columnsStyle}
703703
viewModeResizable={compChildren.viewModeResizable.getView()}
704704
dataSource={pageDataInfo.data}
705705
size={compChildren.size.getView()}
706706
tableLayout="fixed"
707+
height={height}
707708
loading={
708709
loading ||
709710
// fixme isLoading type
@@ -717,6 +718,7 @@ export function TableCompView(props: {
717718
{expansion.expandModalView}
718719
</SlotConfigContext.Provider>
719720
</TableWrapper>
721+
</div>
720722
</BackgroundColorContext.Provider>
721723
);
722724
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ export function compTablePropertyView<T extends MultiBaseComp<TableChildrenType>
429429
<Section name={trans("prop.columns")}>{columnPropertyView(comp)}</Section>
430430
<Section name={sectionNames.layout}>
431431
{comp.children.expansion.getPropertyView()}
432+
{comp.children.autoHeight.getPropertyView()}
432433
{hiddenPropertyView(comp.children)}
433434
</Section>
434435
<Section name={trans("prop.rowSelection")}>
@@ -465,12 +466,6 @@ export function compTablePropertyView<T extends MultiBaseComp<TableChildrenType>
465466
label: trans("table.fixedHeader"),
466467
tooltip: trans("table.fixedHeaderTooltip")
467468
})}
468-
{comp.children.fixedHeader.getView() &&
469-
comp.children.maxHeight.propertyView({
470-
label: trans("table.maxHeight"),
471-
tooltip: trans("table.maxHeightTooltip")
472-
})
473-
}
474469
</Section>
475470
<Section name={"Row Style"}>
476471
{comp.children.rowStyle.getPropertyView()}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { JSONObject } from "util/jsonTypes";
3333
import { ExpansionControl } from "./expansionControl";
3434
import { PaginationControl } from "./paginationControl";
3535
import { SelectionControl } from "./selectionControl";
36+
import { AutoHeightControl } from "comps/controls/autoHeightControl";
3637

3738
const sizeOptions = [
3839
{
@@ -136,7 +137,7 @@ const tableChildrenMap = {
136137
hideBordered: BoolControl,
137138
hideHeader: BoolControl,
138139
fixedHeader: BoolControl,
139-
maxHeight: withDefault(RadiusControl, '300px'),
140+
autoHeight: withDefault(AutoHeightControl, "auto"),
140141
data: withIsLoadingMethod(JSONObjectArrayControl),
141142
showDataLoadSpinner: withDefault(BoolPureControl, true),
142143
columns: ColumnListComp,

client/packages/lowcoder/src/i18n/locales/en.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,6 @@ export const en = {
12501250
hideHeader: "Hide table header",
12511251
fixedHeader: "Fixed table header",
12521252
fixedHeaderTooltip: "Header will be fixed for vertically scrollable table",
1253-
maxHeight: "Max. Height",
1254-
maxHeightTooltip: "Set max. height to make table scrollable",
12551253
hideBordered: "Hide column border",
12561254
deleteColumn: "Delete column",
12571255
confirmDeleteColumn: "Confirm delete column: ",

client/packages/lowcoder/src/i18n/locales/zh.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,8 +1176,6 @@ table: {
11761176
hideHeader: "隐藏表头",
11771177
fixedHeader: "固定表头",
11781178
fixedHeaderTooltip: "垂直滚动表格的标题将被固定",
1179-
maxHeight: "最大限度。高度",
1180-
maxHeightTooltip: "设置最大值使表格可滚动的高度",
11811179
hideBordered: "隐藏列边框",
11821180
deleteColumn: "删除列",
11831181
confirmDeleteColumn: "确认删除列:",

0 commit comments

Comments
 (0)