From 026b6e31a845b17bfd615d1d5768e947e6b8aa71 Mon Sep 17 00:00:00 2001 From: hemengke <23536175@qq.com> Date: Thu, 6 Jan 2022 10:08:55 +0800 Subject: [PATCH] fix: table emptynode fixed display --- src/Body/BodyRow.tsx | 1 + src/Body/ExpandedRow.tsx | 9 +++++++-- src/Body/index.tsx | 1 + src/Table.tsx | 3 ++- src/context/ExpandedRowContext.tsx | 1 + 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Body/BodyRow.tsx b/src/Body/BodyRow.tsx index 5f307cad6..6c2786768 100644 --- a/src/Body/BodyRow.tsx +++ b/src/Body/BodyRow.tsx @@ -196,6 +196,7 @@ function BodyRow( component={RowComponent} cellComponent={cellComponent} colSpan={flattenColumns.length} + isEmpty={false} > {expandContent} diff --git a/src/Body/ExpandedRow.tsx b/src/Body/ExpandedRow.tsx index b3203e8b3..e10399a2f 100644 --- a/src/Body/ExpandedRow.tsx +++ b/src/Body/ExpandedRow.tsx @@ -12,6 +12,7 @@ export interface ExpandedRowProps { expanded: boolean; children: React.ReactNode; colSpan: number; + isEmpty: boolean; } function ExpandedRow({ @@ -22,15 +23,17 @@ function ExpandedRow({ className, expanded, colSpan, + isEmpty, }: ExpandedRowProps) { const { scrollbarSize } = React.useContext(TableContext); - const { fixHeader, fixColumn, componentWidth } = React.useContext(ExpandedRowContext); + const { fixHeader, fixColumn, componentWidth, horizonScroll } = + React.useContext(ExpandedRowContext); // Cache render node return React.useMemo(() => { let contentNode = children; - if (fixColumn) { + if (isEmpty ? horizonScroll : fixColumn) { contentNode = (
({ component={trComponent} cellComponent={tdComponent} colSpan={flattenColumns.length} + isEmpty > {emptyNode} diff --git a/src/Table.tsx b/src/Table.tsx index 6ab97093f..61412de41 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -844,8 +844,9 @@ function Table(props: TableProps ({ onColumnResize }), [onColumnResize]); diff --git a/src/context/ExpandedRowContext.tsx b/src/context/ExpandedRowContext.tsx index 70d46fb20..bbc5eccc0 100644 --- a/src/context/ExpandedRowContext.tsx +++ b/src/context/ExpandedRowContext.tsx @@ -4,6 +4,7 @@ export interface ExpandedRowProps { componentWidth: number; fixHeader: boolean; fixColumn: boolean; + horizonScroll: boolean; } const ExpandedRowContext = React.createContext(null);