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 {
this.updateAssignees([this.currentUser.username]);
},
saveAssignees() {
this.isDirty = false;
this.updateAssignees(this.selected.map(({ username }) => username));
if (this.isDirty) {
this.isDirty = false;
this.updateAssignees(this.selected.map(({ username }) => username));
}
this.$el.dispatchEvent(hideDropdownEvent);
},
collapseWidget() {
......
......@@ -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', () => {
beforeEach(async () => {
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