flowbite-svelte icon indicating copy to clipboard operation
flowbite-svelte copied to clipboard

Toast close events don't propagate

Open selfagency opened this issue 9 months ago • 1 comments

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

selfagency avatar May 15 '24 17:05 selfagency

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.

Daschi1 avatar May 25 '24 17:05 Daschi1

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

gregg-cbs avatar Jul 03 '24 20:07 gregg-cbs

Please try:

  <Toast on:close={() => toastStatus = false}>
    Close me!
  </Toast>

shinokada avatar Jul 04 '24 06:07 shinokada

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

gregg-cbs avatar Jul 05 '24 10:07 gregg-cbs

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

robluton avatar Jul 07 '24 18:07 robluton

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

shinokada avatar Jul 08 '24 03:07 shinokada