Media Library has no close event
Dear Cloudinary-Team,
it looks like Media Library (https://cloudinary.com/documentation/media_library_widget) has no `ml.on('close')` event handler which makes it rather difficult to figure out if the Modal was closed or not when other parts depend on that information. Furthermore there is no way to destroy the instance without the close event (like I can do with the Media Editor):
```tsx
```
Is there a workaround or a solution for this?
FTR: I tried adding `closeHandler` and `showHandler` as well. Nothing happens. But at the same time I do not want to use them, as I let the widget handle that by itself while using `cloudinary.openMediaLibrary`.
I added an example to my demo repository where you can see and test it.
I am only interested in the Modal case at the moment, as the other one does not work in React (see my other issue for this)
Thanks for your help.
-
Hi everyone,
I refactored the code slightly; that’s why the link to the demo is outdated above. Please, start exploring and debugging from here instead: https://github.com/natterstefan/cloudinary-media-library-react-example/blob/ebe8ee46ca25146f7abd86be1dba49aa52e48d46/src/ReactModalExample.tsx#L32
-
Hi Stefan,
Thanks for the additional information, and just to indicate that the close/destroy callback functions are currently unavailable for Media Library Widget as you have highlighted. The possible workaround to address your use case is to provide a component wrapper for the Media Library Widget, where you could handle the disposing of DOM elements - though, this may not be the most elegant approach.
And since your use case is a good recommendation for our product improvement, could you please suggest them on our public roadmap so we could help to follow it up with our internal ticket for the development team? Thanks.
Post is closed for comments.
Comments
2 comments