fix: Clear search input which navigating to other tab/page (#2061)
This commit is contained in:
parent
6c7c5064d1
commit
87078e1abf
4 changed files with 33 additions and 6 deletions
|
@ -116,7 +116,7 @@ export default {
|
||||||
return this.$store.getters['inboxes/getInbox'](this.activeInbox);
|
return this.$store.getters['inboxes/getInbox'](this.activeInbox);
|
||||||
},
|
},
|
||||||
currentPage() {
|
currentPage() {
|
||||||
return this.$store.getters['conversationPage/getCurrentPage'](
|
return this.$store.getters['conversationPage/getCurrentPageFilter'](
|
||||||
this.activeAssigneeTab
|
this.activeAssigneeTab
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -199,6 +199,7 @@ export default {
|
||||||
},
|
},
|
||||||
updateAssigneeTab(selectedTab) {
|
updateAssigneeTab(selectedTab) {
|
||||||
if (this.activeAssigneeTab !== selectedTab) {
|
if (this.activeAssigneeTab !== selectedTab) {
|
||||||
|
bus.$emit('clearSearchInput');
|
||||||
this.activeAssigneeTab = selectedTab;
|
this.activeAssigneeTab = selectedTab;
|
||||||
if (!this.currentPage) {
|
if (!this.currentPage) {
|
||||||
this.fetchConversations();
|
this.fetchConversations();
|
||||||
|
|
|
@ -82,6 +82,7 @@ export default {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
conversations: 'conversationSearch/getConversations',
|
conversations: 'conversationSearch/getConversations',
|
||||||
uiFlags: 'conversationSearch/getUIFlags',
|
uiFlags: 'conversationSearch/getUIFlags',
|
||||||
|
currentPage: 'conversationPage/getCurrentPage',
|
||||||
}),
|
}),
|
||||||
resultsCount() {
|
resultsCount() {
|
||||||
return this.conversations.length;
|
return this.conversations.length;
|
||||||
|
@ -111,10 +112,16 @@ export default {
|
||||||
this.$store.dispatch('conversationSearch/get', { q: newValue });
|
this.$store.dispatch('conversationSearch/get', { q: newValue });
|
||||||
}, 1000);
|
}, 1000);
|
||||||
},
|
},
|
||||||
|
currentPage() {
|
||||||
|
this.clearSearchTerm();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$store.dispatch('conversationSearch/get', { q: '' });
|
this.$store.dispatch('conversationSearch/get', { q: '' });
|
||||||
|
bus.$on('clearSearchInput', () => {
|
||||||
|
this.clearSearchTerm();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -124,6 +131,9 @@ export default {
|
||||||
closeSearch() {
|
closeSearch() {
|
||||||
this.showSearchBox = false;
|
this.showSearchBox = false;
|
||||||
},
|
},
|
||||||
|
clearSearchTerm() {
|
||||||
|
this.searchTerm = '';
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -18,9 +18,12 @@ export const getters = {
|
||||||
getHasEndReached: $state => filter => {
|
getHasEndReached: $state => filter => {
|
||||||
return $state.hasEndReached[filter];
|
return $state.hasEndReached[filter];
|
||||||
},
|
},
|
||||||
getCurrentPage: $state => filter => {
|
getCurrentPageFilter: $state => filter => {
|
||||||
return $state.currentPage[filter];
|
return $state.currentPage[filter];
|
||||||
},
|
},
|
||||||
|
getCurrentPage: $state => {
|
||||||
|
return $state.currentPage;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const actions = {
|
export const actions = {
|
||||||
|
|
|
@ -9,12 +9,25 @@ describe('#getters', () => {
|
||||||
all: 3,
|
all: 3,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
expect(getters.getCurrentPage(state)('me')).toEqual(1);
|
expect(getters.getCurrentPage(state)).toHaveProperty('me');
|
||||||
expect(getters.getCurrentPage(state)('unassigned')).toEqual(2);
|
expect(getters.getCurrentPage(state)).toHaveProperty('unassigned');
|
||||||
expect(getters.getCurrentPage(state)('all')).toEqual(3);
|
expect(getters.getCurrentPage(state)).toHaveProperty('all');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getCurrentPage', () => {
|
it('getCurrentPageFilter', () => {
|
||||||
|
const state = {
|
||||||
|
currentPage: {
|
||||||
|
me: 1,
|
||||||
|
unassigned: 2,
|
||||||
|
all: 3,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
expect(getters.getCurrentPageFilter(state)('me')).toEqual(1);
|
||||||
|
expect(getters.getCurrentPageFilter(state)('unassigned')).toEqual(2);
|
||||||
|
expect(getters.getCurrentPageFilter(state)('all')).toEqual(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('getHasEndReached', () => {
|
||||||
const state = {
|
const state = {
|
||||||
hasEndReached: {
|
hasEndReached: {
|
||||||
me: false,
|
me: false,
|
||||||
|
|
Loading…
Reference in a new issue