diff --git a/packages/bruno-app/src/components/CodeEditor/index.js b/packages/bruno-app/src/components/CodeEditor/index.js index d139d1ec0..27307a0fa 100644 --- a/packages/bruno-app/src/components/CodeEditor/index.js +++ b/packages/bruno-app/src/components/CodeEditor/index.js @@ -192,7 +192,6 @@ export default class CodeEditor extends React.Component { if (editor) { editor.setOption('lint', this.props.mode && editor.getValue().trim().length > 0 ? this.lintOptions : false); editor.on('change', this._onEdit); - editor.on('scroll', this.onScroll); editor.scrollTo(null, this.props.initialScroll); this.addOverlay(); @@ -275,13 +274,19 @@ export default class CodeEditor extends React.Component { componentWillUnmount() { if (this.editor) { + if (this.props.onScroll) { + this.props.onScroll(this.editor); + } + this.editor?._destroyLinkAware?.(); this.editor.off('change', this._onEdit); - this.editor.off('scroll', this.onScroll); // Clean up lint error tooltip this.cleanupLintErrorTooltip?.(); + const wrapper = this.editor.getWrapperElement(); + wrapper?.parentNode?.removeChild(wrapper); + this.editor = null; } } @@ -325,8 +330,6 @@ export default class CodeEditor extends React.Component { this.editor.setOption('mode', 'brunovariables'); }; - onScroll = (event) => this.props.onScroll?.(event); - _onEdit = () => { if (!this.ignoreChangeEvent && this.editor) { this.editor.setOption('lint', this.editor.getValue().trim().length > 0 ? this.lintOptions : false);