bug: when pressing create button multiple times creates duplicate records

if you press the create button multiple times by accident it creates duplicate records
29 Replies
developer
developerOP16mo ago
is there a way to disable the button after being pressed to prevent this behavior?
awcodes
awcodes16mo ago
It should disabled by default when the form is submitted. Can you share some code. Are you doing anything custom with the creation process?
developer
developerOP16mo ago
nothing especial but it takes a few seconds before redirect, so it allows an accidental double-click
awcodes
awcodes16mo ago
So the redirect is happening after the Lw request comes back from the server. It should be disabled until the request comes back.
developer
developerOP16mo ago
wait, i'll show you a video
developer
developerOP16mo ago
developer
developerOP16mo ago
@awcodes As you can see, after clicking on the "create" button, it temporarily deactivates before the redirection (then reactivates) which takes a few seconds, and during that time, it's possible to click multiple times
developer
developerOP16mo ago
awcodes
awcodes16mo ago
Why is it taking so long to redirect? That’s odd. The button uses wire:loading to disable it during requests. So something is taking a long time to redirect after the request comes back from the server.
developer
developerOP16mo ago
I don't know, maybe my pc is kinda slow
awcodes
awcodes16mo ago
Possibly, but I would expect the browser to be that slow.
developer
developerOP16mo ago
I'm using Laragon on windows 10, mariadb + nginx
awcodes
awcodes16mo ago
The request is coming back pretty quick. Can you try it in an incognito browser. I’m wondering if a browser extension could be interfering. It’s definitely something in the browser and not a filament issue though. As best as I can tell based on your vid. I guess the server could be hanging on the redirect but that seems odd to me considering the Lw request is happing so quickly.
developer
developerOP16mo ago
yeah, maybe... but is there a way to hide the button permanently after clicking?
awcodes
awcodes16mo ago
Not really. It’s based on the Lw request. Which it seems to be handling correctly.
developer
developerOP16mo ago
the truth is, I can't control which browser or system users will use I gotta find a solution
awcodes
awcodes16mo ago
Can you share the code for the resource? Just to make sure.
developer
developerOP16mo ago
gimme a second
awcodes
awcodes16mo ago
Also keep in mind that if your browser is doing something weird it doesn’t mean that their browser will do the same thing.
developer
developerOP16mo ago
awcodes
awcodes16mo ago
You can test this by asking a friend or co worker to try using your app on their system. And the rest of the resource?
developer
developerOP16mo ago
btw I already try the official demo https://demo.filamentphp.com/ and it works fine for me so, issue is not browser related
awcodes
awcodes16mo ago
Crazy thought. Try options(fn () => Country::….) on your select. That’s the only thing I’m seeing that you provided that could be causing a delay.
awcodes
awcodes16mo ago
Yea that’s the only standing out to me other than a possible browser issue.
developer
developerOP16mo ago
I changed the table pagination to a smaller number of records, and now it's a bit faster.... from 50 to 5 maybe that's why the redirection takes so long regardless, there should be a way to entirely disable the creation button
awcodes
awcodes16mo ago
I hear you but that’s not necessarily the case. The disabled is working as expected. Do you have Debugbar installed?
developer
developerOP16mo ago
i don't have it hey I'm gonna take a break now
awcodes
awcodes16mo ago
Ok. Install it, publish the config and disable the views to see if there’s a bottleneck at the sql query. Also did you try my suggestion about the options callback. Other than than I’m out of ideas. Especially if you’re not seeing the issue in the demo.
Want results from more Discord servers?
Add your server