From affc7d8ff1bfeb6d48c4fa3a1e8c1350e277c83f Mon Sep 17 00:00:00 2001 From: stephenLYZ <750188453@qq.com> Date: Wed, 21 Sep 2022 21:36:10 +0800 Subject: [PATCH] fix(dashboard): fix Pivot Table V2 dragPreview in the dashboard --- .../src/react-pivottable/Styles.js | 8 ++++---- .../src/react-pivottable/TableRenderers.jsx | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/Styles.js b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/Styles.js index 1360e0dc921ad..5393e4f610f06 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/Styles.js +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/Styles.js @@ -20,9 +20,9 @@ import { css, styled } from '@superset-ui/core'; export const Styles = styled.div` - ${({ theme }) => css` + ${({ theme, isDashboardEditMode }) => css` table.pvtTable { - position: relative; + position: ${isDashboardEditMode ? 'inherit' : 'relative'}; font-size: ${theme.typography.sizes.s}px; text-align: left; margin: ${theme.gridUnit}px; @@ -32,7 +32,7 @@ export const Styles = styled.div` } table thead { - position: sticky; + position: ${isDashboardEditMode ? 'inherit' : 'sticky'}; top: 0; } @@ -51,7 +51,7 @@ export const Styles = styled.div` } table.pvtTable tbody tr.pvtRowTotals { - position: sticky; + position: ${isDashboardEditMode ? 'inherit' : 'sticky'}; bottom: 0; } diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.jsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.jsx index 54b381be28a1d..ea036e99e2963 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.jsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.jsx @@ -826,6 +826,10 @@ export class TableRenderer extends React.Component { ); } + isDashboardEditMode() { + return document.contains(document.querySelector('.dashboard--editing')); + } + render() { if (this.cachedProps !== this.props) { this.cachedProps = this.props; @@ -867,7 +871,7 @@ export class TableRenderer extends React.Component { }; return ( - + {colAttrs.map((c, j) =>