mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
fix(height): (#1800)
- add dynamic height of window "Edit variable" - "Line preview"
This commit is contained in:
parent
ab990d7a40
commit
b4b60f3565
@ -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 ? (
|
||||
<textarea className="danger" value={error || 'Error'} readOnly />
|
||||
) : (
|
||||
<textarea value={preview || ''} readOnly />
|
||||
<textarea ref={this.textAreaRef} value={preview || ''} readOnly />
|
||||
)}
|
||||
</label>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user