mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
fix(editor): Fix read-only mode in inline expression editor (#9232)
This commit is contained in:
parent
0b52320635
commit
99f384e2cf
|
@ -25,14 +25,14 @@ type Props = {
|
||||||
modelValue: string;
|
modelValue: string;
|
||||||
path: string;
|
path: string;
|
||||||
rows?: number;
|
rows?: number;
|
||||||
isReadonly?: boolean;
|
isReadOnly?: boolean;
|
||||||
additionalData?: IDataObject;
|
additionalData?: IDataObject;
|
||||||
eventBus?: EventBus;
|
eventBus?: EventBus;
|
||||||
};
|
};
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
rows: 5,
|
rows: 5,
|
||||||
isReadonly: false,
|
isReadOnly: false,
|
||||||
additionalData: () => ({}),
|
additionalData: () => ({}),
|
||||||
eventBus: () => createEventBus(),
|
eventBus: () => createEventBus(),
|
||||||
});
|
});
|
||||||
|
@ -70,7 +70,7 @@ const {
|
||||||
editorRef: root,
|
editorRef: root,
|
||||||
editorValue,
|
editorValue,
|
||||||
extensions,
|
extensions,
|
||||||
isReadOnly: props.isReadonly,
|
isReadOnly: props.isReadOnly,
|
||||||
autocompleteTelemetry: { enabled: true, parameterPath: props.path },
|
autocompleteTelemetry: { enabled: true, parameterPath: props.path },
|
||||||
additionalData: props.additionalData,
|
additionalData: props.additionalData,
|
||||||
});
|
});
|
||||||
|
|
|
@ -203,6 +203,7 @@ export default defineComponent({
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
.container {
|
.container {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
min-height: 22px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loader {
|
.loader {
|
||||||
|
|
|
@ -47,4 +47,20 @@ describe('ExpressionParameterInput', () => {
|
||||||
await userEvent.click(baseElement);
|
await userEvent.click(baseElement);
|
||||||
expect(emitted('blur')).toHaveLength(1);
|
expect(emitted('blur')).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('in read-only mode', () => {
|
||||||
|
test('it should render a read-only expression input', async () => {
|
||||||
|
const { container } = renderComponent({
|
||||||
|
props: {
|
||||||
|
modelValue: '={{$json.foo}}',
|
||||||
|
isReadOnly: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const editor = container.querySelector('.cm-content') as HTMLDivElement;
|
||||||
|
expect(editor).toBeInTheDocument();
|
||||||
|
expect(editor.getAttribute('contenteditable')).toEqual('false');
|
||||||
|
expect(editor.getAttribute('aria-readonly')).toEqual('true');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue