Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Fix read-only mode in inline expression editor #9232

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ type Props = {
modelValue: string;
path: string;
rows?: number;
isReadonly?: boolean;
isReadOnly?: boolean;
additionalData?: IDataObject;
eventBus?: EventBus;
};

const props = withDefaults(defineProps<Props>(), {
rows: 5,
isReadonly: false,
isReadOnly: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why this wasn't caught build time by e.g. typescript?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, it seems inconsistent: for some components I get TypeScript errors and others I don't, even in very similar components:

image image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we unfortunately do not have build-time type checking yet.

additionalData: () => ({}),
eventBus: () => createEventBus(),
});
Expand Down Expand Up @@ -70,7 +70,7 @@ const {
editorRef: root,
editorValue,
extensions,
isReadOnly: props.isReadonly,
isReadOnly: props.isReadOnly,
autocompleteTelemetry: { enabled: true, parameterPath: props.path },
additionalData: props.additionalData,
});
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/components/ParameterOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export default defineComponent({
<style lang="scss" module>
.container {
display: flex;
min-height: 22px;
}

.loader {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,20 @@ describe('ExpressionParameterInput', () => {
await userEvent.click(baseElement);
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