Evo-Forge / Essence

Essence - The Essential Material Design Framework
MIT License
416 stars 51 forks source link

[essence-stepper] Provides a way to cancel next step #53

Open sntran opened 8 years ago

sntran commented 8 years ago

I am using essence-steppers to provide multi-step sign up form. My form need to perform client-side validations on each step. However, clicking "Continue" will always advance to next step.

I propose the following to allow the onContinue callback not to advance to next step:

https://github.com/Evo-Forge/Essence/blob/master/components/essence-stepper/src/stepper.jsx#L46-L57

    continueStepper(callback) {
        let nextStep = this.state.currentStep + 1;
        let cancelled = false;

        if (callback) {
            cancelled = callback(nextStep) === false;
        }

        if (!cancelled) {
            this.setState({
                selected: nextStep,
                currentStep: nextStep
            });
        }
    }

I can open a PR if this is reasonable.

hetmann commented 8 years ago

Nice suggestion. I will take in consideration this issue.