function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shivram survaseshivram survase 

How to close the parent LWC component from child LWC component popup model on button click.?

I have a lightning Web component like this:
Component A: Parent Component
Component B: Child Component
I'm calling Component B from Component A on button click.
I want to implent either of the below. Any suggestions/help appreciated.
1.  I want to close the Component A automatically when Component B popup model is showed up on button click.
2. Else I want close the Component A automatically when Component B popup model is closed.
VinayVinay (Salesforce Developers) 
HI Shivram,

Check below example.

https://developer.salesforce.com/forums/?id=9060G0000005qnBQAQ

Please mark as Best Answer if above information was helpful.

Thanks,
mukesh guptamukesh gupta
Hi Shivram,

It's not possible, bceause Component B is embedded in Componnent A, if you try to close Component A then ComponentB will automatically close.

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
Arta mantArta mant
Hello If you're wondering what casino is the best place to spend your time, there's no doubt about it. Immediately I can tell you that you should go to this site tangiers casino vip (https://tangiers.casinologincanada.com/) . Here you can find the best casino for yourself with the ability to make quick money and get fast fun.
Pamela Johnson 9Pamela Johnson 9
Ah, the classic "how to close the parent LWC component from the child LWC component popup model on button click" dilemma. It's like a delightful little puzzle that keeps us LWC enthusiasts on our toes! Now, let me tell you about my mystake (pun intended) when I encountered a similar situation. I was once working on a project where I needed to achieve this exact feat. At first, I tried to be clever, attempting various convoluted approaches that left me scratching my virtual head. But, alas! My mystake (https://www.vpesports.com/betting/mystake) was assuming it had to be complicated. In a stroke of inspiration, I decided to embrace simplicity and utilize custom events. With a few lines of code, I established a beautiful communication between the child and parent components, allowing me to gracefully close the parent component from the popup model on button click. It was a victorious moment of LWC brilliance! Remember, folks, sometimes the best solutions hide in plain sight! Happy coding!
Andrew BelottiAndrew Belotti
In order to close the parent LWC component from a child LWC component popup model on button click, you can establish a communication channel between the two components using events. When the button is clicked in the child component, fire an event and handle it in the parent component to trigger the closing action. You can find detailed steps and code examples in the Salesforce Lightning Web Components documentation. Also, you can explore additional resources at https://affiliazionescommesse.com/ (https://affiliazionescommesse.com/)for more insights and solutions related to LWC development and Salesforce platform. Remember to follow best practices to ensure smooth communication and functionality between the components.