From d5159dcfa023b6cb5753a0d3d2f726946ed16e34 Mon Sep 17 00:00:00 2001 From: Bjorn Stromberg Date: Fri, 11 Sep 2020 23:21:41 +0900 Subject: [PATCH] [Performance] Calculate height instead of letting the browser do it --- modules/ui/sections/raw_tag_editor.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/ui/sections/raw_tag_editor.js b/modules/ui/sections/raw_tag_editor.js index 4fcb9b3c8..bdb012542 100644 --- a/modules/ui/sections/raw_tag_editor.js +++ b/modules/ui/sections/raw_tag_editor.js @@ -285,8 +285,11 @@ export function uiSectionRawTagEditor(id, context) { if (_tagView !== 'text') return; var selection = d3_select(this); - selection.style('height', null); - selection.style('height', selection.node().scrollHeight + 5 + 'px'); + var matches = selection.node().value.match(/\n/g); + var lineCount = 2 + Number(matches && matches.length); + var lineHeight = 20; + + selection.style('height', lineCount * lineHeight + 'px'); } function stringify(s) {