Skip to content

Commit 5e19bdf

Browse files
PytalPVince81
authored andcommitted
Reset global search on files sidebar navigation change
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent f263930 commit 5e19bdf

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

apps/files/js/app.js

+2
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@
309309
this._changeUrl(params.view, params.dir);
310310
OC.Apps.hideAppSidebar($('.detailsView'));
311311
this.navigation.getActiveContainer().trigger(new $.Event('urlChanged', params));
312+
window._nc_event_bus.emit('files:navigation:changed')
312313
}
313314
},
314315

@@ -360,6 +361,7 @@
360361
this.navigation.getActiveContainer().trigger(new $.Event('show'));
361362
}
362363
this.navigation.getActiveContainer().trigger(new $.Event('urlChanged', params));
364+
window._nc_event_bus.emit('files:navigation:changed')
363365
},
364366

365367
/**

core/src/views/UnifiedSearch.vue

+10-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
</template>
124124

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

@@ -300,10 +300,15 @@ export default {
300300
},
301301

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

308+
beforeDestroy() {
309+
unsubscribe('files:navigation:changed', this.resetForm)
310+
},
311+
307312
mounted() {
308313
document.addEventListener('keydown', (event) => {
309314
// if not already opened, allows us to trigger default browser on second keydown
@@ -338,6 +343,10 @@ export default {
338343
emit('nextcloud:unified-search.close')
339344
},
340345

346+
resetForm() {
347+
this.$el.querySelector('form[role="search"]').reset()
348+
},
349+
341350
/**
342351
* Reset the search state
343352
*/

dist/core-unified-search.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-unified-search.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)