epicmaxco / vuestic-ui

Vuestic UI is an open-source Vue 3 component library designed for rapid development, easy maintenance, and high accessibility. Maintained by Epicmax (@epicmaxco).
https://vuestic.dev
MIT License
3.47k stars 337 forks source link

beforeLeave props must expect Promise #3906

Open m0ksem opened 1 year ago

m0ksem commented 1 year ago

Right now, beforeLeave in VaStepper expects false to be returned to prevent navigation. We need also expect promise and if it resolves false.

Maybe better pass next() function the same way we do with VaModal.

Expect beforeLeave to return false, undefined - means navigation should be handled manually with next() function which passed as third argument to beforeLeave. We also need to handle if result is promise and wait for it to be resolved.

Example:

const steps = [{
 label: 'First',

 beforeLeave(prevStep, nextStep, next) {
    getUser().then((user) => user !== null && next())
 }
}]
Bond-Addict commented 1 year ago

@m0ksem Another issue I've seen with the stepper is that being on the final step doesnt trigger beforeLeave either. There also doesnt seem (as far as the documentation goes) a finish button option when you're using the custom slots option either.