diff --git a/src/components/Item/VisualizationItem/Item.js b/src/components/Item/VisualizationItem/Item.js index d94043a90..2ce84fa6d 100644 --- a/src/components/Item/VisualizationItem/Item.js +++ b/src/components/Item/VisualizationItem/Item.js @@ -29,6 +29,7 @@ import memoizeOne from '../../../modules/memoizeOne'; import { colors } from '@dhis2/ui-core'; import { getVisualizationConfig } from './plugin'; import LoadingMask from './LoadingMask'; +import { ITEM_CONTENT_PADDING_BOTTOM } from '../../ItemGrid/ItemGrid'; const styles = { icon: { @@ -169,13 +170,19 @@ export class Item extends Component { ); } + const calculatedHeight = + this.props.item.originalHeight - + this.headerRef.current.clientHeight - + HEADER_MARGIN_HEIGHT - + ITEM_CONTENT_PADDING_BOTTOM; + const props = { ...this.props, visualization, style: this.memoizedGetContentStyle( - this.props.item.originalHeight, - this.headerRef.current.clientHeight, - this.contentRef ? this.contentRef.offsetHeight : null + calculatedHeight, + this.contentRef ? this.contentRef.offsetHeight : null, + this.props.editMode ), }; @@ -280,13 +287,12 @@ export class Item extends Component { this.props.visualization ); - getContentStyle = (originalHeight, headerHeight, measuredHeight) => { - const calculatedHeight = - originalHeight - headerHeight - HEADER_MARGIN_HEIGHT; + getContentStyle = (calculatedHeight, measuredHeight, editMode) => { + const height = editMode + ? measuredHeight || calculatedHeight + : calculatedHeight; - return { - height: measuredHeight || calculatedHeight, - }; + return { height }; }; render() { diff --git a/src/components/ItemGrid/ItemGrid.js b/src/components/ItemGrid/ItemGrid.js index df9eb7a7a..0f1fd56e3 100644 --- a/src/components/ItemGrid/ItemGrid.js +++ b/src/components/ItemGrid/ItemGrid.js @@ -44,6 +44,8 @@ import ProgressiveLoadingContainer from '../Item/ProgressiveLoadingContainer'; // Component const EXPANDED_HEIGHT = 17; +// this is set in the .dashboard-item-content css +export const ITEM_CONTENT_PADDING_BOTTOM = 4; export class ItemGrid extends Component { state = {