Commit 9cccc5fd authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'bug-fix-project-dropdown-not-able-to-deselect' into 'master'

Fix analytics dropdown deselect bug

See merge request gitlab-org/gitlab!16778
parents 2d58bd00 66ed49c5
......@@ -80,10 +80,13 @@ export default {
? this.selectedProjects.concat([selectedProject])
: this.selectedProjects.filter(project => project.id !== selectedProject.id);
},
singleSelectedProject(selectedObj, isMarking) {
return isMarking ? [selectedObj] : [];
},
setSelectedProjects(selectedObj, isMarking) {
this.selectedProjects = this.multiSelect
? this.getSelectedProjects(selectedObj, isMarking)
: [selectedObj];
: this.singleSelectedProject(selectedObj, isMarking);
},
onClick({ selectedObj, e, isMarking }) {
e.preventDefault();
......
......@@ -141,6 +141,23 @@ describe('ProjectsDropdownFilter component', () => {
]);
});
it('selection should be emptied when a project is deselected', () => {
const project = findDropdownItems().at(0);
project.trigger('click');
project.trigger('click');
expect(wrapper.emittedByOrder()).toEqual([
{
name: 'selected',
args: [[projects[0]]],
},
{
name: 'selected',
args: [[]],
},
]);
});
it('renders an avatar in the dropdown button when the project has an avatar_url', done => {
findDropdownItems()
.at(0)
......
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