mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-28 22:19:41 -08:00
fix(editor): Prevent deleting a sticky note while editing (no-changelog) (#11576)
This commit is contained in:
parent
0a05aa4862
commit
c0aa67b8f0
|
@ -62,6 +62,7 @@ const isTouchActive = ref<boolean>(false);
|
||||||
const forceActions = ref(false);
|
const forceActions = ref(false);
|
||||||
const isColorPopoverVisible = ref(false);
|
const isColorPopoverVisible = ref(false);
|
||||||
const stickOptions = ref<HTMLElement>();
|
const stickOptions = ref<HTMLElement>();
|
||||||
|
const isEditing = ref(false);
|
||||||
|
|
||||||
const setForceActions = (value: boolean) => {
|
const setForceActions = (value: boolean) => {
|
||||||
forceActions.value = value;
|
forceActions.value = value;
|
||||||
|
@ -147,8 +148,13 @@ const workflowRunning = computed(() => uiStore.isActionActive.workflowRunning);
|
||||||
|
|
||||||
const showActions = computed(
|
const showActions = computed(
|
||||||
() =>
|
() =>
|
||||||
!(props.hideActions || props.isReadOnly || workflowRunning.value || isResizing.value) ||
|
!(
|
||||||
forceActions.value,
|
props.hideActions ||
|
||||||
|
isEditing.value ||
|
||||||
|
props.isReadOnly ||
|
||||||
|
workflowRunning.value ||
|
||||||
|
isResizing.value
|
||||||
|
) || forceActions.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
@ -187,6 +193,7 @@ const changeColor = (index: number) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onEdit = (edit: boolean) => {
|
const onEdit = (edit: boolean) => {
|
||||||
|
isEditing.value = edit;
|
||||||
if (edit && !props.isActive && node.value) {
|
if (edit && !props.isActive && node.value) {
|
||||||
ndvStore.activeNodeName = node.value.name;
|
ndvStore.activeNodeName = node.value.name;
|
||||||
} else if (props.isActive && !edit) {
|
} else if (props.isActive && !edit) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { createComponentRenderer } from '@/__tests__/render';
|
||||||
import { createCanvasNodeProvide } from '@/__tests__/data';
|
import { createCanvasNodeProvide } from '@/__tests__/data';
|
||||||
import { createTestingPinia } from '@pinia/testing';
|
import { createTestingPinia } from '@pinia/testing';
|
||||||
import { setActivePinia } from 'pinia';
|
import { setActivePinia } from 'pinia';
|
||||||
|
import { fireEvent } from '@testing-library/vue';
|
||||||
|
|
||||||
const renderComponent = createComponentRenderer(CanvasNodeStickyNote);
|
const renderComponent = createComponentRenderer(CanvasNodeStickyNote);
|
||||||
|
|
||||||
|
@ -42,4 +43,29 @@ describe('CanvasNodeStickyNote', () => {
|
||||||
|
|
||||||
expect(resizeControls).toHaveLength(0);
|
expect(resizeControls).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should disable sticky options when in edit mode', async () => {
|
||||||
|
const { container } = renderComponent({
|
||||||
|
global: {
|
||||||
|
provide: {
|
||||||
|
...createCanvasNodeProvide({
|
||||||
|
id: 'sticky',
|
||||||
|
readOnly: false,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const stickyTextarea = container.querySelector('.sticky-textarea');
|
||||||
|
|
||||||
|
if (!stickyTextarea) return;
|
||||||
|
|
||||||
|
await fireEvent.dblClick(stickyTextarea);
|
||||||
|
|
||||||
|
const stickyOptions = container.querySelector('.sticky-options');
|
||||||
|
|
||||||
|
if (!stickyOptions) return;
|
||||||
|
|
||||||
|
expect(getComputedStyle(stickyOptions).display).toBe('none');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue