fix(editor): Prevent deleting a sticky note while editing (no-changelog) (#11576)

This commit is contained in:
Ricardo Espinoza 2024-11-11 07:02:26 -05:00 committed by GitHub
parent 0a05aa4862
commit c0aa67b8f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 35 additions and 2 deletions

View file

@ -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) {

View file

@ -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');
});
}); });