From b4b60f3565b77ce03b536158dfc0dabe18d987d1 Mon Sep 17 00:00:00 2001 From: kliques Date: Fri, 22 Nov 2019 19:38:27 +0200 Subject: [PATCH] fix(height): (#1800) - add dynamic height of window "Edit variable" - "Line preview" --- .../ui/components/templating/variable-editor.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/insomnia-app/app/ui/components/templating/variable-editor.js b/packages/insomnia-app/app/ui/components/templating/variable-editor.js index f500d724e..b325e0760 100644 --- a/packages/insomnia-app/app/ui/components/templating/variable-editor.js +++ b/packages/insomnia-app/app/ui/components/templating/variable-editor.js @@ -6,7 +6,7 @@ import autobind from 'autobind-decorator'; class VariableEditor extends PureComponent { constructor(props) { super(props); - + this.textAreaRef = React.createRef(); const inner = props.defaultValue.replace(/\s*}}$/, '').replace(/^{{\s*/, ''); this.state = { @@ -19,6 +19,11 @@ class VariableEditor extends PureComponent { componentDidMount() { this._update(this.state.value, true); + this._resize(); + } + + componentDidUpdate() { + this._resize(); } _handleChange(e) { @@ -26,6 +31,14 @@ class VariableEditor extends PureComponent { this._update(name); } + _resize() { + setTimeout(() => { + const element = this.textAreaRef.current; + element.style.cssText = 'height: auto, padding: 0'; + element.style.cssText = `height:${element.scrollHeight}px`; + }, 100); + } + _setSelectRef(n) { this._select = n; @@ -95,7 +108,7 @@ class VariableEditor extends PureComponent { {error ? (