themesberg / flowbite

Open-source UI component library and front-end development framework based on Tailwind CSS
https://flowbite.com
MIT License
7.31k stars 710 forks source link

Adds support for re-init after Turbo Stream #760

Closed sdhull closed 5 months ago

sdhull commented 6 months ago

Also DRYs up the init functions so you don't have to maintain the list in multiple places ✨

In this I introduce a new turbo event (turbo:after-stream-render) for parity with the other turbo events, and then use it to register another re-init listener. This may be more invasive that you want (that is, it essentially monkey-patches a new event into Turbo). I can remove the event if you like, it seems harmless and maybe useful for others so figured I'd try this way first.

This has been a long time coming since I figured out how to fix this—please let me know if I'm missing anything, I'm not particularly well-versed in Typescript.

I tested this out locally and it seemed to work fine. Didn't see any tests in the repo 👀

zoltanszogyenyi commented 6 months ago

Hey @sdhull,

Thanks a lot for this PR! Will have it properly checked next year (first week).

Cheers, Zoltan