Commit 05236934 authored by Florie Guibert's avatar Florie Guibert

Swimlanes - Fix grabbing cursor on drag

parent 7472a375
...@@ -103,7 +103,11 @@ export default { ...@@ -103,7 +103,11 @@ export default {
showIssue(issue) { showIssue(issue) {
this.setActiveId({ id: issue.id, sidebarType: ISSUABLE }); this.setActiveId({ id: issue.id, sidebarType: ISSUABLE });
}, },
handleDragOnStart() {
document.body.classList.add('is-dragging');
},
handleDragOnEnd(params) { handleDragOnEnd(params) {
document.body.classList.remove('is-dragging');
const { newIndex, oldIndex, from, to, item } = params; const { newIndex, oldIndex, from, to, item } = params;
const { issueId, issueIid, issuePath } = item.dataset; const { issueId, issueIid, issuePath } = item.dataset;
const { children } = to; const { children } = to;
...@@ -163,6 +167,8 @@ export default { ...@@ -163,6 +167,8 @@ export default {
v-if="list.isExpanded" v-if="list.isExpanded"
v-bind="treeRootOptions" v-bind="treeRootOptions"
class="board-cell gl-p-2 gl-m-0 gl-h-full" class="board-cell gl-p-2 gl-m-0 gl-h-full"
data-testid="tree-root-wrapper"
@start="handleDragOnStart"
@end="handleDragOnEnd" @end="handleDragOnEnd"
> >
<board-card-layout <board-card-layout
......
...@@ -55,6 +55,7 @@ describe('IssuesLaneList', () => { ...@@ -55,6 +55,7 @@ describe('IssuesLaneList', () => {
list, list,
issues: mockIssues, issues: mockIssues,
disabled: false, disabled: false,
canAdminList: true,
}, },
}); });
}; };
...@@ -96,4 +97,52 @@ describe('IssuesLaneList', () => { ...@@ -96,4 +97,52 @@ describe('IssuesLaneList', () => {
expect(wrapper.findAll(BoardCard)).toHaveLength(0); expect(wrapper.findAll(BoardCard)).toHaveLength(0);
}); });
}); });
describe('drag & drop issue', () => {
beforeEach(() => {
const defaultStore = createStore();
store = {
...defaultStore,
state: {
...defaultStore.state,
canAdminEpic: true,
},
};
createComponent();
});
describe('handleDragOnStart', () => {
it('adds a class `is-dragging` to document body', () => {
expect(document.body.classList.contains('is-dragging')).toBe(false);
wrapper.find(`[data-testid="tree-root-wrapper"]`).vm.$emit('start');
expect(document.body.classList.contains('is-dragging')).toBe(true);
});
});
describe('handleDragOnEnd', () => {
it('removes class `is-dragging` from document body', () => {
jest.spyOn(wrapper.vm, 'moveIssue').mockImplementation(() => {});
document.body.classList.add('is-dragging');
wrapper.find(`[data-testid="tree-root-wrapper"]`).vm.$emit('end', {
oldIndex: 1,
newIndex: 0,
item: {
dataset: {
issueId: mockIssues[0].id,
issueIid: mockIssues[0].iid,
issuePath: mockIssues[0].referencePath,
},
},
to: { children: [], dataset: { listId: 'gid://gitlab/List/1' } },
from: { dataset: { listId: 'gid://gitlab/List/2' } },
});
expect(document.body.classList.contains('is-dragging')).toBe(false);
});
});
});
}); });
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