mattjennings / svelte-modals

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

error on opening #14

Closed thisispete closed 2 years ago

thisispete commented 2 years ago

getting an error on opening modals,

Using the example from the repo, it looks like it's trying to create the Modal but it's getting a PointerEvent instead of the modal class definition?

Screen Shot 2022-05-18 at 14 54 35

Svelte-modals 1.1 Svelte 3.48 SvelteKit 1.0.0-next.326

mattjennings commented 2 years ago

Are you by any chance passing openModal to an on:click instead of a handler function?

If not, can you reproduce this in a Svelte REPL? You can base it off this one

thisispete commented 2 years ago

yep on:click

seeing it open if I use

onMount(() => {
  openModal(Modal, { title: "Alert", message: "This is an alert" })
})
thisispete commented 2 years ago

oh, I see, my bad, I had on:click={openModal} should be on:click={handleClick}

 const handleClick = () => {
    openModal(Modal, { title: "Alert", message: "This is an alert" })
  }