Commit d7424385 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'kp-fix-duplicate-token-keys' into 'master'

Fix bugs around Filtered Search Bar

See merge request gitlab-org/gitlab!39452
parents beb7dfaf 0e1f4ce3
......@@ -121,7 +121,9 @@ export default {
: __('Sort direction: Descending');
},
filteredRecentSearches() {
return this.recentSearches.filter(item => typeof item !== 'string');
return this.recentSearchesStorageKey
? this.recentSearches.filter(item => typeof item !== 'string')
: undefined;
},
},
watch: {
......@@ -280,7 +282,7 @@ export default {
<template #history-item="{ historyItem }">
<template v-for="(token, index) in historyItem">
<span v-if="typeof token === 'string'" :key="index" class="gl-px-1">"{{ token }}"</span>
<span v-else :key="`${token.type}-${token.value.data}`" class="gl-px-1">
<span v-else :key="`${index}-${token.type}-${token.value.data}`" class="gl-px-1">
<span v-if="tokenTitles[token.type]"
>{{ tokenTitles[token.type] }} :{{ token.value.operator }}</span
>
......
......@@ -130,6 +130,16 @@ describe('FilteredSearchBarRoot', () => {
expect(wrapper.vm.filteredRecentSearches).toHaveLength(1);
expect(wrapper.vm.filteredRecentSearches[0]).toEqual({ foo: 'bar' });
});
it('returns undefined when recentSearchesStorageKey prop is not set on component', async () => {
wrapper.setProps({
recentSearchesStorageKey: '',
});
await wrapper.vm.$nextTick();
expect(wrapper.vm.filteredRecentSearches).not.toBeDefined();
});
});
});
......
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