diff --git a/shell/components/CodeMirror.vue b/shell/components/CodeMirror.vue index 44e702a11fc..df677f55ef9 100644 --- a/shell/components/CodeMirror.vue +++ b/shell/components/CodeMirror.vue @@ -42,6 +42,7 @@ export default { hasLintErrors: false, currFocusedElem: undefined, isCodeMirrorFocused: false, + lastValue: '', codeMirrorContainerRef: undefined }; }, @@ -214,12 +215,26 @@ export default { this.$nextTick(() => { codeMirrorRef.refresh(); this.codeMirrorRef = codeMirrorRef; + this.lastValue = this.value; }); this.$emit('onReady', codeMirrorRef); }, - onInput(newCode) { - this.$emit('onInput', newCode); + onInput() { + if (!this.codeMirrorRef) return; + + const actualValue = this.codeMirrorRef.getValue(); + + if (this.lastValue.length > actualValue.length && actualValue === ' ') { + this.codeMirrorRef.setValue(''); + this.lastValue = ''; + this.$emit('onInput', ''); + + return; + } + + this.lastValue = actualValue; + this.$emit('onInput', actualValue); }, onChanges(codeMirrorRef, changes) {