Open
Description
Versions:
@inertiajs/core
version: 2.0.4@inertiajs/vue2
version: #.#.#@inertiajs/vue3
version: 2.0.4@inertiajs/react
version: #.#.#@inertiajs/svelte
version: #.#.#
Describe the problem:
There is currently no way to know, when a client visit is done (with replace: true
)
It uses promises internally but those are not exposed. Neither an event is fired.
popstate
only fires on navigation (not whenreplaceState
orpushState
is used).insertia:finish
only fires when doing server visitsinertia:navigate
only fires whenreplace: false
Steps to reproduce:
Hard to come up with a reproduction that shows that nothing happens :D
document.addEventListener('inertia:finish', console.log)
document.addEventListener('inertia:navigate', console.log)
window.addEventListener('popstate', console.log)
router.replace({
preserveScroll: true,
preserveState: true,
props: {
foo: 5
}
})
Possible solutions
Imo, the best solution by far would be to just return the promises by returning it here:
inertia/packages/core/src/router.ts
Lines 290 to 307 in 4efe682
and here:
inertia/packages/core/src/router.ts
Lines 282 to 288 in 4efe682
Another solution could be adding yet another event. However, that is a bit weird to use when you only want to react to one specific router visit. Hence I think that exposing the promises is the superior solution
Metadata
Metadata
Assignees
Labels
No labels