Skip to content

Commit

Permalink
Merge pull request #34100 from nextcloud/fix/reset-global-search
Browse files Browse the repository at this point in the history
Reset global search on files sidebar navigation change
  • Loading branch information
PVince81 authored Sep 16, 2022
2 parents 88b6644 + a7c7d84 commit 8b6f5a4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions apps/files/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@
this._changeUrl(params.view, params.dir);
OC.Apps.hideAppSidebar($('.detailsView'));
this.navigation.getActiveContainer().trigger(new $.Event('urlChanged', params));
window._nc_event_bus.emit('files:navigation:changed')
}
},

Expand Down Expand Up @@ -374,6 +375,7 @@
this.navigation.getActiveContainer().trigger(new $.Event('show'));
}
this.navigation.getActiveContainer().trigger(new $.Event('urlChanged', params));
window._nc_event_bus.emit('files:navigation:changed')
},

/**
Expand Down
11 changes: 10 additions & 1 deletion core/src/views/UnifiedSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
</template>

<script>
import { emit } from '@nextcloud/event-bus'
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
import { minSearchLength, getTypes, search, defaultLimit, regexFilterIn, regexFilterNot, enableLiveSearch } from '../services/UnifiedSearchService'
import { showError } from '@nextcloud/dialogs'

Expand Down Expand Up @@ -329,10 +329,15 @@ export default {
},

async created() {
subscribe('files:navigation:changed', this.resetForm)
this.types = await getTypes()
this.logger.debug('Unified Search initialized with the following providers', this.types)
},

beforeDestroy() {
unsubscribe('files:navigation:changed', this.resetForm)
},

mounted() {
if (OCP.Accessibility.disableKeyboardShortcuts()) {
return
Expand Down Expand Up @@ -371,6 +376,10 @@ export default {
emit('nextcloud:unified-search.close')
},

resetForm() {
this.$el.querySelector('form[role="search"]').reset()
},

/**
* Reset the search state
*/
Expand Down
4 changes: 2 additions & 2 deletions dist/core-unified-search.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-unified-search.js.map

Large diffs are not rendered by default.

0 comments on commit 8b6f5a4

Please sign in to comment.