Skip to content

Commit

Permalink
Merge pull request #34106 from nextcloud/backport/34100/stable24
Browse files Browse the repository at this point in the history
[stable24] Reset global search on files sidebar navigation change
  • Loading branch information
PVince81 authored Sep 16, 2022
2 parents 5e09063 + 5e19bdf commit cb0bfae
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 @@ -309,6 +309,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 @@ -360,6 +361,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 @@ -123,7 +123,7 @@
</template>

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

Expand Down Expand Up @@ -300,10 +300,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() {
document.addEventListener('keydown', (event) => {
// if not already opened, allows us to trigger default browser on second keydown
Expand Down Expand Up @@ -338,6 +343,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 cb0bfae

Please sign in to comment.