Skip to content

Commit

Permalink
fix: back button unresponsive after network switch (#1662)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomiir committed Dec 26, 2023
1 parent b36153e commit 13b71a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 10 additions & 0 deletions packages/core/src/controllers/RouterController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,15 @@ export const RouterController = {
state.view = last
}
}
},

goBackToIndex(historyIndex: number) {
if (state.history.length > 1) {
state.history = state.history.slice(0, historyIndex + 1)
const [last] = state.history.slice(-1)
if (last) {
state.view = last
}
}
}
}
5 changes: 2 additions & 3 deletions packages/core/src/utils/RouterUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ export const RouterUtil = {
navigateAfterNetworkSwitch() {
const { history } = RouterController.state
const networkSelectIndex = history.findIndex(name => name === 'Networks')
const pageBeforeNetworkSelect = history[networkSelectIndex - 1]
if (pageBeforeNetworkSelect) {
RouterController.replace(pageBeforeNetworkSelect)
if (networkSelectIndex >= 1) {
RouterController.goBackToIndex(networkSelectIndex - 1)
} else {
ModalController.close()
}
Expand Down

3 comments on commit 13b71a0

@vercel
Copy link

@vercel vercel bot commented on 13b71a0 Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 13b71a0 Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 13b71a0 Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.