themesberg / flowbite-svelte

Official Svelte components built for Flowbite and Tailwind CSS
https://flowbite-svelte.com
MIT License
2.13k stars 265 forks source link

Toast close events don't propagate #1348

Closed selfagency closed 2 months ago

selfagency commented 4 months ago

Describe the bug

The on:close event on the Toast component does not bubble up and therefore cannot trigger a secondary function (like removing the toast data from my state manager).

It works on version 0.44.24. But 45 and up, it's broken.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-zmyrcp?file=src%2Froutes%2F%2Bpage.svelte

Make sure the package.json says 0.46.1 and that it wasn't rewritten cuz I had a weird problem where it reset to 0.44.24 on its own.

Flowbite version and System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @sveltejs/kit: ^2.5.4 => 2.5.4 
    flowbite-svelte: ^0.46.1 => 0.46.1 
    svelte: ^4.2.12 => 4.2.12 
    vite: ^5.1.6 => 5.1.6
Daschi1 commented 4 months ago

Yes, I am experiencing the same issue. Additionally, the open property is no longer exported from the Toast component, which prevents binding to it using bind:open. Upon reviewing the source code, it appears that TransitionFrame.svelte is masking it.

gregg-cbs commented 3 months ago

Same here, toast has no events... on:close doesnt exist? If it is dismissable how do you know if it has closed?

shinokada commented 3 months ago

Please try:

  <Toast on:close={() => toastStatus = false}>
    Close me!
  </Toast>
gregg-cbs commented 3 months ago

I did do that, the on:close event is not fired and my ide is acting as if it does not exist

robluton commented 2 months ago

Ran into the same issue. I submitted a PR for a potential fix. Hats off to the maintainers and contributors of this library! It's a joy to use. https://github.com/themesberg/flowbite-svelte/pull/1383

shinokada commented 2 months ago

https://github.com/themesberg/flowbite-svelte/pull/1383 merged. Thank you.