CloudWatch: Fix code editor not resizing on mount when content height is > 200px (#81911)

This commit is contained in:
Kevin Yu 2024-02-09 09:44:29 -08:00 committed by GitHub
parent 42d6e176bc
commit 7f109c885d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;