From 7f109c885d673e11718c37a43bc2128823bbda0e Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Fri, 9 Feb 2024 09:44:29 -0800 Subject: [PATCH] CloudWatch: Fix code editor not resizing on mount when content height is > 200px (#81911) --- .../MetricsQueryEditor/MathExpressionQueryField.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/MathExpressionQueryField.tsx b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/MathExpressionQueryField.tsx index 110d8171c10..5ac7ca8e226 100644 --- a/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/MathExpressionQueryField.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/QueryEditor/MetricsQueryEditor/MathExpressionQueryField.tsx @@ -29,8 +29,9 @@ export function MathExpressionQueryField({ expression: query, onChange, datasour // We may wish to consider abstracting it into the grafana/ui repo in the future const updateElementHeight = () => { const containerDiv = containerRef.current; - if (containerDiv !== null && editor.getContentHeight() < 200) { - const pixelHeight = Math.max(32, editor.getContentHeight()); + if (containerDiv !== null) { + const maxPixelHeight = Math.min(200, editor.getContentHeight()); + const pixelHeight = Math.max(32, maxPixelHeight); containerDiv.style.height = `${pixelHeight}px`; containerDiv.style.width = '100%'; const pixelWidth = containerDiv.clientWidth;