Skip to content

Commit

Permalink
Persist active tab via URL query param
Browse files Browse the repository at this point in the history
  • Loading branch information
smilingkylan committed Dec 13, 2023
1 parent e19ec58 commit a388e77
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/pages/Account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ export default defineComponent({
await store.dispatch('account/updateABI', route.params.account);
});
const onChangeTab = async (newTab: string) => {
await router.push({
// taking care to preserve the current #hash anchor and the current query parameters
hash: window.location.hash,
query: {
...route.query,
tab:newTab,
},
});
};
watch([tab], () => {
void router.push({
path: router.currentRoute.value.path,
Expand All @@ -52,6 +63,7 @@ export default defineComponent({
});
return {
onChangeTab,
tab,
account,
abi,
Expand All @@ -68,7 +80,12 @@ export default defineComponent({
<div class="row">
<AccountCard class="account-card" :account="account" :tokens="tokenList"/>
</div>
<q-tabs v-model="tab" class="account-view tabs" no-caps>
<q-tabs
v-model="tab"
class="account-view tabs"
no-caps
@update:model-value="onChangeTab"
>
<q-tab v-if="!accountPageSettings.hideTransactionTab" name="transactions" label="Transactions"/>
<q-tab v-if="!accountPageSettings.hideContractsTab && abi" name="contract" label="Contract"/>
<q-tab v-if="!accountPageSettings.hideTokensTab" name="tokens" label="Tokens"/>
Expand Down

0 comments on commit a388e77

Please sign in to comment.