mattjennings / svelte-modals

A simple, flexible, zero-dependency modal stack manager for Svelte.
https://svelte-modals.mattjennings.io
154 stars 8 forks source link

Possible to keep all modals visible? #13

Closed countnazgul closed 2 weeks ago

countnazgul commented 2 years ago

Im trying to create something like this: image

By passing $modals.length I can make the necessary css changes (applying some padding/margin to each modal) to create the layout but my problem is that only the last/active modal is kept visible.

mattjennings commented 2 years ago

If you don't use the isOpen prop in your modal components they will all stay visible.

However, if you wanted to have multiple modals open and close them individually in arbitrary order, there's no way to do that currently. closeModal() etc. will always closes the most recent first.

Maybe it would make sense to support closing modals by a generated id or something, I'll have to think about that.

mattjennings commented 2 weeks ago

closeById has been added to v2.0.0, so by ignoring isOpen that should enable this use case

id can be provided to modals.open