Closing a modal inside a the modal

  • 19 October 2022
  • 4 replies
  • 144 views

Badge +1

Hey,

i was wondering if it is possible to close a modal without klicking the close button “x”.

 

I want to open an external side with “miro.board.ui.openModal({url: ‘https://external.local’})” method. 

Is there any way to close the modal from the external webside external.local.

 

Thank you


4 replies

Userlevel 2
Badge +1

Hi @leon_00 

Thank you for reaching out, and cool that you're building using the Miro Web SDK!

If I understand your use case correctly, you want to open a modal, and then you want to be able to close it from a panel.

To do this, you can:

  • Open a modal.
  • Open a panel.
  • In the file with the code that controls the panel, add a link or a button that listens to the icon:click event.
  • Clicking the link or button on the panel causes the icon:click event to fire, and it can trigger the closeModal method to close the open modal.

Would this approach work for you?

Badge +1

Hey @Marco Spinello,

i think i was not specific enough.

  1. open the main applikation with openPanel
  2. inside the panel i press a button which fires an event
    1. it closes the panel with the main applikation closePanel
    2. it opens a modal with different applikation openModal

My question starts here

Is it possible to close this model without pressing the button “x”.

For example the modal has a simple form as its content. And the user has two buttons “ok” and “cancel”. Is it possible to close the modal by clicking the buttons?

 



Picture from: https://community.miro.com/developer-platform-and-apis-57/how-to-get-modal-value-when-close-the-modal-on-web-sdk2-9459

 

Thank you

Userlevel 5

Hi @leon_00 

 

You can do so by calling the Close Modal method. 

We have a code example of this here: https://github.com/miroapp/app-examples/blob/c4a9c54485b9b530641cd8c79bf2a2e3a74f8d7c/examples/github-appcards/src/appcard-modal.tsx#L165

 

Hopefully this helps!

Badge +1

Hey @Addison Schultz,

unfortunately this does not work. As stated in the documentation:

ℹ️ Note:

  • To close an open modal, closeModal must execute after openModal.
  • The app that closes the modal with closeModal must be the same that opened it with openModal.

Since the modal contains a completely different application it has no infomation of state of the other application.

Thanks anyway

Reply