inertia icon indicating copy to clipboard operation
inertia copied to clipboard

VisitOptions missing from global event detail object

Open wijzijnweb opened this issue 4 months ago • 1 comments

Version:

  • @inertiajs/vue3 version: 1.2.0

Describe the problem:

When having a global event the VisitOptions are not passed to the event object. document.addEventListener('inertia:before', checkForUnsavedChanges)

function checkForUnsavedChanges(event) {
    // event misses the VisitOptions
}

So we capture the visit event. Check if there are unsaved changes. If the user wants to move away anyway I want to redo the visit call.

router.visit(currentEvent.value.detail.visit.url, currentEvent.value.detail.visit)

But of course when the user confirms we remove the event listener so it doesn't trigger the modal again. We don't use js confirm because the requirement is that there are multiple options. Cancel, move away, or save. These are shown in a modal. Besides that confirm is quite ugly.

If orignal event callbacks can be added to the event details that would be great!

wijzijnweb avatar Oct 11 '24 09:10 wijzijnweb