Commit 1d425a87 authored by Florie Guibert's avatar Florie Guibert

Prevent mutation assignee widget without changes

Prevent firing mutation when editing and exiting assignee widget without changes
parent 6f0bab97
...@@ -175,8 +175,10 @@ export default { ...@@ -175,8 +175,10 @@ export default {
this.updateAssignees([this.currentUser.username]); this.updateAssignees([this.currentUser.username]);
}, },
saveAssignees() { saveAssignees() {
this.isDirty = false; if (this.isDirty) {
this.updateAssignees(this.selected.map(({ username }) => username)); this.isDirty = false;
this.updateAssignees(this.selected.map(({ username }) => username));
}
this.$el.dispatchEvent(hideDropdownEvent); this.$el.dispatchEvent(hideDropdownEvent);
}, },
collapseWidget() { collapseWidget() {
......
...@@ -208,6 +208,22 @@ describe('Sidebar assignees widget', () => { ...@@ -208,6 +208,22 @@ describe('Sidebar assignees widget', () => {
]); ]);
}); });
it('does not trigger mutation or fire event when editing and exiting without making changes', async () => {
createComponent();
await waitForPromises();
findEditableItem().vm.$emit('open');
await waitForPromises();
findEditableItem().vm.$emit('close');
expect(findEditableItem().props('isDirty')).toBe(false);
expect(updateIssueAssigneesMutationSuccess).toHaveBeenCalledTimes(0);
expect(wrapper.emitted('assignees-updated')).toBe(undefined);
});
describe('when expanded', () => { describe('when expanded', () => {
beforeEach(async () => { beforeEach(async () => {
createComponent(); createComponent();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment