Skip to content

Vue: Expose Inertia.js Lifecycle Events in the reload Slot Prop #179

@erikhamrin-fk

Description

@erikhamrin-fk

Bug Report

Description

I am requesting the addition of the standard Inertia.js lifecycle events (onStart, onFinish, onSuccess, and onError) as arguments to the reload slot prop function within the Modal component.

When utilizing the reload slot prop to trigger a page reload after an action within the modal, I have limited visibility into the navigation state. This makes it challenging to implement common UI patterns like:
Showing a loading indicator when the reload request starts (onStart).
Hiding the loading indicator regardless of the outcome (onFinish).
Displaying a success message or closing the modal when the reload is complete and successful (onSuccess).
Handling and logging an error if the navigation fails (onError).

Steps To Reproduce

<script setup>
defineProps(['permissions'])
performReload = (reload) => {
    reload({ 
        only: ['permissions'] }, 
        onStart: () => console.log('started'), 
        onSuccess: () => console.log('success')
    })
}
</script>

<template>
    <Modal #default="{ reload }">
        <button @click="performReload(reload)">
            Reload permissions
        </button>
    </Modal>
</template>

Expected Behavior

Console log with "started"

Actual Behavior

Nothing happens

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions