Open stefanfisk opened 4 days ago
@stefanfisk, this is by design.
Could you outline the exact issue you are facing in your application?
@timacdonald I have two use cases where this has caused me issues, both for when the user submits the form.
The first use case is to focus the first input with an error. So when the user submits the form it is fully validated and then the first input with an error is focused. If the user tries to submit a second time without actually editing the form the same thing should happen again.
The second use case is a form where I want to perform a file upload to S3 before actually submitting the form. So my idea was to:
The workaround with onBeforeValidation
is fine for me since the number of extra requests should be low. But I was very confused when validate()
sometimes simply did nothing and I could find no mention of this behavior in the changelog or pull request.
Unless I am mistaken your example with the Next button in https://github.com/laravel/precognition/pull/69 will also result in the button not actually doing anything on consecutive clicks. So if the user does not notice the first message about the form having validation errors the button is just dead until the user edits the form or does something else that triggers a validation so that the previous request no longer matches the next
request.
Laravel Precognition Plugin Version
0.5.7
Laravel Version
10.43
Plugin
Alpine
Description
The async
validate()
handlers are not called if the request is equal to the previous request.If I understand everything correctly the root cause is that
onBeforeValidation()
short circuits the request.As a workaround
onBeforeValidation: () => true
can be added to thevalidate()
config.Steps To Reproduce
Call the following code twice. The second time it will not output anything.