Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LWC Wizard Next button Click unable to call model popup #1

Closed
kranthik2330 opened this issue Jun 11, 2020 · 2 comments
Closed

LWC Wizard Next button Click unable to call model popup #1

kranthik2330 opened this issue Jun 11, 2020 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@kranthik2330
Copy link

Hello Guys,

I have 2 screens in the wizard (Step1 and Step2)
As soon a user clicks on Next button on the first screen (Step #1). Before doing any custom validation i want to call model confirmation popup Like below.
Once user clicks on close then i want to do validation on the screen and move to next step "Step#2

Please provide me with possible solution for this request.

C Wizard Model popup

@jmpisson jmpisson self-assigned this Jun 17, 2020
@jmpisson jmpisson added the question Further information is requested label Jun 17, 2020
@jmpisson
Copy link
Owner

Hi there @kranthik2330 ! The best option you have is to just override the Next button to perform your custom logic.

You can easily do this by using the hideNextButton property and the actions slot on c-wizard-stepcomponent. For example, in your container component you could write something like this:

template.html

<template>
    <c-wizard header="Create Account Flow" variant="path" current-step="step-1" oncomplete={saveAccount}>
        <c-wizard-step label="Create Account" name="step-1" hide-next-button>
            <!-- YOUR FORM --><!-- / YOUR FORM -->

            <!-- YOUR MODAL -->
            <template if:true={isModalShown}>
                 <!-- MODAL CONTENT -->
            </template>
            <!-- / MODAL -->

            <!-- CUSTOM ACTIONS -->
            <lightning-button label="Next" variant="brand" slot="actions" onclick={openModal}></lightning-button>
            <!-- / CUSTOM ACTIONS -->
        </c-wizard-step>
        
           <!-- OTHER STEPS -->
    </c-wizard>
</template>

component.js

export default class CustomlWizard extends NavigationMixin(LightningElement) {

    openModal() {
        this.isModalShown = true;
    }

    closeModal() {
        this.isModalShown = false;
    }

    // Executes the validation with the modal "Next" button
    next() {
         // If custom validation works...
        if(this.validate()) {
            // Advances to the next step
            this.template.querySelector('c-wizard').currentStep = 'step-2';
        }
       // Close modal on every case
        this.closeModal();
    }

    validate() {
        return true;
    }

With this code, you will get somehting like this:
imagen

I have just push to the repo a little example with this logic, within the examples folder; Hope it helps!

@kranthik2330
Copy link
Author

This is the best answer thank you for all your work and support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants