+ Start a Discussion
saimounikasaimounika 

Field Reset for a lightning-input-field(Picklist) fires Onchange event in LWC

Hi All,

I have a component with lightning-record-edit-form which has lightning-input-field . The field is of data type "PicklList" and it has a onchange event. I am displaying the save and cancel button on change of picklist.

 On click of cancel I am resetting the picklist fields using field.reset() and setting the boolean variable(which is used to hide button) to False.

However, On click of cancel field reset is triggering the onchange event and making the boolean variable(which is used to hide button)to true and displaying the buttons.

I found a link in which salesforce provided a solution to a similar issue in Aura.
https://help.salesforce.com/articleView?id=000352380&language=en_US&mode=1&type=1 

Could you please help me with this issue in LWC?
saimounikasaimounika
Fixed it by using a boolean variable.
Suraj Tripathi 47Suraj Tripathi 47
Hi saimounika,
you have to add another boolean variable in the component and check their value in the component js file onChange.According to your click event change on cancel button.
If you facing any problem then reply me

if you find your Solution then mark it as the best answer 
thanks and Regards
Malika Pathak.