Skip to content

Commit

Permalink
fix(editor): Prevent deleting a sticky note while editing (no-changel…
Browse files Browse the repository at this point in the history
…og) (#11576)
  • Loading branch information
RicardoE105 authored Nov 11, 2024
1 parent 0a05aa4 commit c0aa67b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/editor-ui/src/components/Sticky.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const isTouchActive = ref<boolean>(false);
const forceActions = ref(false);
const isColorPopoverVisible = ref(false);
const stickOptions = ref<HTMLElement>();
const isEditing = ref(false);
const setForceActions = (value: boolean) => {
forceActions.value = value;
Expand Down Expand Up @@ -147,8 +148,13 @@ const workflowRunning = computed(() => uiStore.isActionActive.workflowRunning);
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(() => {
Expand Down Expand Up @@ -187,6 +193,7 @@ const changeColor = (index: number) => {
};
const onEdit = (edit: boolean) => {
isEditing.value = edit;
if (edit && !props.isActive && node.value) {
ndvStore.activeNodeName = node.value.name;
} else if (props.isActive && !edit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createComponentRenderer } from '@/__tests__/render';
import { createCanvasNodeProvide } from '@/__tests__/data';
import { createTestingPinia } from '@pinia/testing';
import { setActivePinia } from 'pinia';
import { fireEvent } from '@testing-library/vue';

const renderComponent = createComponentRenderer(CanvasNodeStickyNote);

Expand Down Expand Up @@ -42,4 +43,29 @@ describe('CanvasNodeStickyNote', () => {

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

0 comments on commit c0aa67b

Please sign in to comment.