Make search work correctly when clicking on results

This commit is contained in:
Dane Everitt 2018-09-11 22:24:48 -07:00
parent 31092df5df
commit 201c8a7c4c
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 36 additions and 17 deletions

View file

@ -18,7 +18,7 @@
</div>
</div>
<div class="mt-6 sidenav mr-6 bg-white border rounded">
<router-link :to="{ name: 'server', params: { id: this.$route.params.id } }">
<router-link :to="{ name: 'server', params: { id: $route.params.id } }">
<terminal-icon class="h-4"></terminal-icon> Console
</router-link>
<router-link :to="{ name: 'server-files' }">
@ -51,7 +51,7 @@
</div>
</div>
-->
<router-view></router-view>
<router-view :key="server.identifier"></router-view>
</div>
</div>
</div>
@ -87,6 +87,18 @@
...mapState('socket', ['connected', 'connectionError']),
},
// Watch for route changes that occur with different server parameters. This occurs when a user
// uses the search bar. Because of the way vue-router works, it won't re-mount the server component
// so we will end up seeing the wrong server data if we don't perform this watch.
watch: {
'$route': function (toRoute, fromRoute) {
if (toRoute.params.id !== fromRoute.params.id) {
this.loadingServerData = true;
this.loadServer();
}
}
},
data: function () {
return {
loadingServerData: true,