lightning-wizard icon indicating copy to clipboard operation
lightning-wizard copied to clipboard

Calling to Child Method doesn't working

Open carmineromano995 opened this issue 3 years ago • 4 comments

carmineromano995 avatar Jul 18 '22 14:07 carmineromano995

Hi @carmineromano99! Sorry for the delayed response; I will test the behaviour, but at first I think you should use this.querySelector('c-asset-move-search-account');. Your component c-asset-move-search-account is child from the template of c-wizard.

When you are triggering logic from c-wizard-step, c-asset-move-search-account lives on the slot, and it is not part from the parent template, so in this case you should use directly this.querySelector.

Hope it helps!

jmpisson avatar Jul 26 '22 09:07 jmpisson

Hi @jmpisson It works, thanks a lot.

Do you know if It's possible to set variables in a parent lwc of c-wizard-step? When the method set in the before-change attribute fires, "this" variable is set on c-wizard-step. For example in the LWC createAccountWizard I created a variable that I would set in the before-change method of step 1. When I'm in the Step 2 the variable of createAccountWizard is Undefined

carmineromano995 avatar Jul 26 '22 14:07 carmineromano995

Hi @carmineromano995! By design, I decided to make the validation aware only on the step, so currently it's not possible in a standardized way to set a variable on top of c-wizard-step - I have planned to include the parent directly on the validation, but I haven't work on this feature still.

Maybe the easiest way to share a context between your steps is to use a shared module between components - this way you could store the form state between all steps.

jmpisson avatar Aug 02 '22 09:08 jmpisson

Hi @jmpisson, I'll share a use case: I need to take some information from the User input in each Step and only in the last step use the user input/selection to do some operation (Eg: Insert a record). Each step can contain LWC child where the user makes some input info, chooses a row from a data table, or search record from a search bar. In the before-change event of each step, I would like to save the user input/selection in the parent LWC for using them in the last Step.

I hope I was clear.

Thanks

carmineromano995 avatar Aug 05 '22 07:08 carmineromano995