Skip to content

Commit a7c7d84

Browse files
committed
Reset global search on files sidebar navigation change
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent ca747b9 commit a7c7d84

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

apps/files/js/app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@
323323
this._changeUrl(params.view, params.dir);
324324
OC.Apps.hideAppSidebar($('.detailsView'));
325325
this.navigation.getActiveContainer().trigger(new $.Event('urlChanged', params));
326+
window._nc_event_bus.emit('files:navigation:changed')
326327
}
327328
},
328329

@@ -374,6 +375,7 @@
374375
this.navigation.getActiveContainer().trigger(new $.Event('show'));
375376
}
376377
this.navigation.getActiveContainer().trigger(new $.Event('urlChanged', params));
378+
window._nc_event_bus.emit('files:navigation:changed')
377379
},
378380

379381
/**

core/src/views/UnifiedSearch.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
</template>
151151

152152
<script>
153-
import { emit } from '@nextcloud/event-bus'
153+
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
154154
import { minSearchLength, getTypes, search, defaultLimit, regexFilterIn, regexFilterNot, enableLiveSearch } from '../services/UnifiedSearchService'
155155
import { showError } from '@nextcloud/dialogs'
156156
@@ -329,10 +329,15 @@ export default {
329329
},
330330
331331
async created() {
332+
subscribe('files:navigation:changed', this.resetForm)
332333
this.types = await getTypes()
333334
this.logger.debug('Unified Search initialized with the following providers', this.types)
334335
},
335336
337+
beforeDestroy() {
338+
unsubscribe('files:navigation:changed', this.resetForm)
339+
},
340+
336341
mounted() {
337342
if (OCP.Accessibility.disableKeyboardShortcuts()) {
338343
return
@@ -371,6 +376,10 @@ export default {
371376
emit('nextcloud:unified-search.close')
372377
},
373378
379+
resetForm() {
380+
this.$el.querySelector('form[role="search"]').reset()
381+
},
382+
374383
/**
375384
* Reset the search state
376385
*/

dist/core-unified-search.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-unified-search.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)