Commit 6534e8ae authored by Mark Florian's avatar Mark Florian

Merge branch '220828-fix-filters-clear-event-handler' into 'master'

Fix search filters not clearing on clear button click

Closes #220828

See merge request gitlab-org/gitlab!34137
parents 5200e024 f09c5339
......@@ -462,16 +462,18 @@ export default {
},
handleFilterRequirements(filters = []) {
const authors = [];
let textSearch = '';
filters.forEach(filter => {
if (typeof filter === 'string') {
this.textSearch = filter;
textSearch = filter;
} else if (filter.value.data !== ANY_AUTHOR) {
authors.push(filter.value.data);
}
});
this.authorUsernames = [...authors];
this.textSearch = textSearch;
this.currentPage = 1;
this.prevPageCursor = '';
this.nextPageCursor = '';
......
......@@ -667,6 +667,18 @@ describe('RequirementsRoot', () => {
`http://localhost/?page=1&state=opened&search=foo&sort=created_desc&author_username%5B%5D=root&author_username%5B%5D=john.doe`,
);
});
it('updates props `textSearch` and `authorUsernames` with empty values when passed filters param is empty', () => {
wrapper.setData({
authorUsernames: ['foo'],
textSearch: 'bar',
});
wrapper.vm.handleFilterRequirements([]);
expect(wrapper.vm.authorUsernames).toEqual([]);
expect(wrapper.vm.textSearch).toBe('');
});
});
describe('handleSortRequirements', () => {
......
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