Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rendering of old/wrong set of resources in search list #9881

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions changelog/unreleased/bugfix-search-list-result-rendering
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Bugfix: Prevent rendering of old/wrong set of resources in search list

When entering the search, it displayed the resources from the file list for a short moment,
this has now been fixed and the search always shows the loading spinner first.

After all results have been loaded from the server, the spinner disappears and the result is rendered.

https://github.com/owncloud/web/pull/9881
https://github.com/owncloud/web/issues/9790
5 changes: 5 additions & 0 deletions packages/web-app-files/src/components/Search/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ export default defineComponent({
})

onMounted(async () => {
// Store resources are shared across table views, therefore
// the store state needs a reset to prevent the old list of resources
// from being rendered while the request retrieves the new resources from the server.
store.commit('Files/CLEAR_CURRENT_FILES_LIST', null)

if (unref(hasTags)) {
await loadAvailableTagsTask.perform()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ describe('List component', () => {
const { wrapper } = getWrapper({ resources: [mock<Resource>()] })
expect(wrapper.find(selectors.resourceTableStub).exists()).toBeTruthy()
})
it('resets the initial store file state', () => {
const { storeOptions } = getWrapper({ resources: [mock<Resource>()] })
expect(storeOptions.modules.Files.mutations.CLEAR_CURRENT_FILES_LIST).toHaveBeenCalled()
})
it('should emit search event on mount', async () => {
const { wrapper } = getWrapper()
await wrapper.vm.loadAvailableTagsTask.last
Expand Down Expand Up @@ -197,6 +201,7 @@ function getWrapper({
})
const store = createStore(storeOptions)
return {
storeOptions,
mocks,
wrapper: shallowMount(List, {
global: {
Expand Down
4 changes: 3 additions & 1 deletion packages/web-app-search/src/views/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export default defineComponent({
return listSearch
})

const loading = ref(false)
// The resources always have to be loaded from the server first.
// Therefore, the loading spinner is active by default, which prevents incorrect results from being displayed.
const loading = ref(true)
const searchResult = ref({
values: [],
totalResults: null
Expand Down
4 changes: 4 additions & 0 deletions packages/web-app-search/tests/unit/views/List.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ describe('search result List view', () => {
const { wrapper } = getWrapper()
expect(wrapper.vm.listSearch).toMatchObject(mockProvider.listSearch)
})
it('by default loading is true', () => {
const { wrapper } = getWrapper()
expect(wrapper.vm.loading).toBeTruthy()
})
it('triggers the search', async () => {
const { wrapper } = getWrapper()
await wrapper.vm.search('term')
Expand Down