Set CodeMirror `readonly` flag to `true` to enable copy (#14426)

This updates the `readonly` flag to `true` instead of `nocursor` when the CodeMirror component is in View mode. The copy event will not fire when type `ctrl + C` or `Command + C`; this stems from the fact that the editor never receives focus when `nocursor` is used.

To resolve this issue, we can use a boolean value for `readonly` and ensure that the container focus is not set to true when in View mode to prevent help text from rendering.

Signed-off-by: Phillip Rak <rak.phillip@gmail.com>
This commit is contained in:
Phillip Rak 2025-06-03 13:31:27 -06:00 committed by GitHub
parent 4288c1008e
commit c52840635e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -88,7 +88,7 @@ export default {
// fixes https://github.com/rancher/dashboard/issues/13653
// we can't use the inert HTML prop on the parent because it disables all interaction
out.readOnly = this.isDisabled ? 'nocursor' : false;
out.readOnly = !!this.isDisabled;
return out;
},
@ -227,8 +227,8 @@ export default {
},
onFocus() {
this.isCodeMirrorFocused = true;
this.$emit('onFocus', true);
this.isCodeMirrorFocused = !this.isDisabled;
this.$emit('onFocus', this.isCodeMirrorFocused);
},
onBlur() {