-
Notifications
You must be signed in to change notification settings - Fork 766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails Turbo Frames multiple backdrops issues #698
Comments
Hey @WozniakMac, Thanks for reporting, I'll have a look tomorrow. Cheers, |
My first few takes on this:
I'll also post a Ruby on Rails starter on GitHub with Flowbite pre-installed. Thanks, |
Fixed the double/multiple backdrop issue for the modal. It was an init check issue. Will be added to The situation is as follows:
Will investigate further. By the way, you can test the new modal fix by pinning this JS resource:
Until a fix is provided, for all Ruby on Rails users, I recommend using the latest stable version of Flowbite pre-v2.0 as there are no differences of features other than the main Instance Manager update. |
@zoltanszogyenyi Thanks mate! It looks like this time modal stopped working and I can't open it twice :D. Only first modal open and only once. After it all modal stopped working :D. Could be because I load turbo frame after opening the modal. I'll try to dig into it deeper later. Maybe my first diagnose was not fully correct. Btw. I think you create new package by mistake https://www.npmjs.com/package/flowbite-2.0 |
Hey @WozniakMac, Thanks for testing - it's a new package because I'm just testing things out :) Released one more package:
This should always override the instances for the modals and drawers. I think that if you want to dig deeper, you can fork the Flowbite project and make releases on a new repo name, something like
All you need to do when you have forked the Flowbite lib is to run These are the files that you need to check out: https://github.com/themesberg/flowbite/blob/main/src/index.turbo.ts (this is where we set up the turbo and frame load events) I've debugged this for over 3 hours and couldn't find a fix and I'm also not very experienced with Ruby on Rails, so your help here would be invaluable. Either way, I'll check this in the following days too. I'm here to help and collaborate on a fix. You also may want to check for the Cheers, |
@zoltanszogyenyi For now I have a workaround for both issues. I use my own package on gihub based on 1.8 with support for load-frame events turned off. It works fine because I don't need to load flowbite components in frames. Tested 2.0.3. It's funny too :D |
@zoltanszogyenyi I found out what is the issue. Every time you call Because of this after loading turbo frame on page it adds new event listener to modal button which calls Telling you so you are not wasting time debugging. Trying to figure out how to fix it now |
@zoltanszogyenyi It looks like I fixed it 🎉 🎉 |
Hey @WozniakMac, Appreciate the PR! I did my own fix though, because I wanted to keep everything nice and tidy in terms of classes. Here's my commit that fixes the issue: db93b3e Basically, I keep a store of all event listeners for each instance and destroy them when also destroying the instance. The problem with your solution is that you created another instance manager when we already had one. Please install this version and test it on your repo: https://www.npmjs.com/package/flowbite-2.1.0 This will be pushed to v2.1.0 later today or tomorrow. Thanks! |
@zoltanszogyenyi https://github.com/WozniakMac/flowbite-issue-demo I'm going to use my fork for now. |
Hey @WozniakMac , Thanks for the feedback. What exactly breaks? Right now, the event listeners are being added for each new instance. I'll take a look tomorrow - this works for my local turbo frame load repository. Cheers, |
Please make sure you use this package: https://www.npmjs.com/package/flowbite-2.1.0 |
I have the same problem with sidebar drawer. I tried the package you mentioned and the same issue still exists. In the first page load I got 2 messages saying Drawer3.prototype._destroyBackdropEl = function() {
if (this._visible) {
document.querySelector("[drawer-backdrop]").remove();
}
}; Setting flowbite/src/components/drawer/index.ts Line 86 in cc5320a
Any ideas on how to solve this? Maybe just fix the always deleting issue, and we can use |
To hack the issue for now, I disabled backdrops, and added |
I'm seeing the same issue as @AliOsm - any navigation away from a drawer link results in
Definitely related to Turbo because if you add Great suggestion to add the empty div at the end of the body!! Hopefully we get a cleaner fix soon. |
Describe the bug
When loading frame in rails with turbo it is initialising all components again which makes modals and drawers create multiple backdrops. It sometimes makes screen grey and you need to refresh the whole window.
It looks like this code is responsible for it. https://github.com/themesberg/flowbite/blob/main/src/index.turbo.ts#L31-L44
Instead of initialising only new components it initialise those which are already initialised again. And that makes multiple backdrops.
Removing it fixes the issue but it will stop initialising new components in turbo frames.
To Reproduce
Steps to reproduce the behaviour:
Demo: https://github.com/WozniakMac/flowbite-issue-demo
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: