Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Hide cursor in the readonly native editor (#63774)

Alexander Polyankinf901d08b1cae
diff --git a/e2e/test/scenarios/actions/model-actions.cy.spec.js b/e2e/test/scenarios/actions/model-actions.cy.spec.js
index e34191f5ebf..0ab5c766c98 100644
--- a/e2e/test/scenarios/actions/model-actions.cy.spec.js
+++ b/e2e/test/scenarios/actions/model-actions.cy.spec.js
@@ -812,10 +812,7 @@ function openActionEditorFor(actionName, { isReadOnly = false } = {}) {
}
function assertQueryEditorDisabled() {
- // Ace doesn't act as a normal input, so we can't use `should("be.disabled")`
- // Instead we'd assert that a user can't type in the editor
- H.fillActionQuery("QWERTY");
- cy.findByText("QWERTY").should("not.exist");
+ H.NativeEditor.get().should("have.attr", "contenteditable", "false");
}
function enableSharingFor(actionName, { publicUrlAlias }) {
diff --git a/frontend/src/metabase/common/components/CodeMirror/CodeMirror.tsx b/frontend/src/metabase/common/components/CodeMirror/CodeMirror.tsx
index 53e1b7dc690..4f08a0c7ef1 100644
--- a/frontend/src/metabase/common/components/CodeMirror/CodeMirror.tsx
+++ b/frontend/src/metabase/common/components/CodeMirror/CodeMirror.tsx
@@ -28,6 +28,7 @@ export const CodeMirror = forwardRef(function CodeMirrorInner(
autoCorrect,
tabIndex,
extensions,
+ readOnly,
...rest
} = props;
@@ -53,6 +54,8 @@ export const CodeMirror = forwardRef(function CodeMirrorInner(
className={cx(S.editor, className)}
basicSetup={setup}
extensions={extendedExtensions}
+ readOnly={readOnly}
+ editable={!readOnly}
/>
);
});