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
is there a way to disable the button after being pressed to prevent this behavior?
It should disabled by default when the form is submitted. Can you share some code. Are you doing anything custom with the creation process?
nothing especial but it takes a few seconds before redirect, so it allows an accidental double-click
So the redirect is happening after the Lw request comes back from the server. It should be disabled until the request comes back.
wait, i'll show you a video
@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
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.
I don't know, maybe my pc is kinda slow
Possibly, but I would expect the browser to be that slow.
I'm using Laragon on windows 10, mariadb + nginx
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.
yeah, maybe... but is there a way to hide the button permanently after clicking?
Not really. It’s based on the Lw request.
Which it seems to be handling correctly.
the truth is, I can't control which browser or system users will use
I gotta find a solution
Can you share the code for the resource?
Just to make sure.
gimme a second
Also keep in mind that if your browser is doing something weird it doesn’t mean that their browser will do the same thing.
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?
btw I already try the official demo https://demo.filamentphp.com/ and it works fine for me
so, issue is not browser related
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.
Yea that’s the only standing out to me other than a possible browser issue.
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
I hear you but that’s not necessarily the case. The disabled is working as expected. Do you have Debugbar installed?
i don't have it
hey I'm gonna take a break now
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.