mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(editor): Focus editable text input when clicking anywhere on the element (#17780)
This commit is contained in:
@@ -193,7 +193,6 @@ describe('Credentials', () => {
|
|||||||
credentialsModal.actions.fillCredentialsForm();
|
credentialsModal.actions.fillCredentialsForm();
|
||||||
workflowPage.getters.nodeCredentialsEditButton().click();
|
workflowPage.getters.nodeCredentialsEditButton().click();
|
||||||
credentialsModal.getters.credentialsEditModal().should('be.visible');
|
credentialsModal.getters.credentialsEditModal().should('be.visible');
|
||||||
credentialsModal.getters.name().click();
|
|
||||||
credentialsModal.actions.renameCredential(NEW_CREDENTIAL_NAME);
|
credentialsModal.actions.renameCredential(NEW_CREDENTIAL_NAME);
|
||||||
saveCredential();
|
saveCredential();
|
||||||
credentialsModal.getters.closeButton().click();
|
credentialsModal.getters.closeButton().click();
|
||||||
@@ -211,7 +210,6 @@ describe('Credentials', () => {
|
|||||||
cy.get('body').type('{enter}');
|
cy.get('body').type('{enter}');
|
||||||
workflowPage.getters.nodeCredentialsEditButton().click();
|
workflowPage.getters.nodeCredentialsEditButton().click();
|
||||||
credentialsModal.getters.credentialsEditModal().should('be.visible');
|
credentialsModal.getters.credentialsEditModal().should('be.visible');
|
||||||
credentialsModal.getters.name().click();
|
|
||||||
credentialsModal.actions.renameCredential(NEW_CREDENTIAL_NAME2);
|
credentialsModal.actions.renameCredential(NEW_CREDENTIAL_NAME2);
|
||||||
saveCredential();
|
saveCredential();
|
||||||
credentialsModal.getters.closeButton().click();
|
credentialsModal.getters.closeButton().click();
|
||||||
@@ -236,7 +234,6 @@ describe('Credentials', () => {
|
|||||||
credentialsModal.actions.fillCredentialsForm();
|
credentialsModal.actions.fillCredentialsForm();
|
||||||
workflowPage.getters.nodeCredentialsEditButton().click();
|
workflowPage.getters.nodeCredentialsEditButton().click();
|
||||||
credentialsModal.getters.credentialsEditModal().should('be.visible');
|
credentialsModal.getters.credentialsEditModal().should('be.visible');
|
||||||
credentialsModal.getters.name().click();
|
|
||||||
credentialsModal.actions.renameCredential(NEW_CREDENTIAL_NAME);
|
credentialsModal.actions.renameCredential(NEW_CREDENTIAL_NAME);
|
||||||
saveCredential();
|
saveCredential();
|
||||||
credentialsModal.getters.closeButton().click();
|
credentialsModal.getters.closeButton().click();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const Template: StoryFn = (args, { argTypes }) => ({
|
|||||||
},
|
},
|
||||||
template: `
|
template: `
|
||||||
<div class="story">
|
<div class="story">
|
||||||
<N8nInlineTextEdit v-bind="args" />
|
<InlineTextEdit v-bind="args" />
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -105,4 +105,24 @@ describe('N8nInlineTextEdit', () => {
|
|||||||
const emittedEvents = wrapper.emitted('update:model-value');
|
const emittedEvents = wrapper.emitted('update:model-value');
|
||||||
expect(emittedEvents).toBeUndefined();
|
expect(emittedEvents).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should focus input when any child element is clicked', async () => {
|
||||||
|
const wrapper = renderComponent({
|
||||||
|
props: {
|
||||||
|
modelValue: 'Test Value',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const editableArea = wrapper.getByTestId('inline-editable-area');
|
||||||
|
const rect = editableArea.getBoundingClientRect();
|
||||||
|
|
||||||
|
// Click the bottom right corner of the parent element
|
||||||
|
await userEvent.pointer([
|
||||||
|
{ coords: { clientX: rect.right - 1, clientY: rect.bottom - 1 } },
|
||||||
|
{ target: editableArea },
|
||||||
|
{ keys: '[MouseLeft]' },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const input = wrapper.getByTestId('inline-edit-input');
|
||||||
|
expect(input).toHaveFocus();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ const computedInlineStyles = computed(() => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
function forceFocus() {
|
function forceFocus() {
|
||||||
if (editableRoot.value && !props.readOnly) {
|
if (editableRoot.value && !props.readOnly && !props.disabled) {
|
||||||
editableRoot.value.edit();
|
editableRoot.value.edit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,6 +101,7 @@ defineExpose({ forceFocus, forceCancel });
|
|||||||
:readonly="readOnly"
|
:readonly="readOnly"
|
||||||
select-on-focus
|
select-on-focus
|
||||||
auto-resize
|
auto-resize
|
||||||
|
@click="forceFocus"
|
||||||
@submit="onSubmit"
|
@submit="onSubmit"
|
||||||
@update:model-value="onInput"
|
@update:model-value="onInput"
|
||||||
@update:state="onStateChange"
|
@update:state="onStateChange"
|
||||||
|
|||||||
Reference in New Issue
Block a user