@@ -165,7 +165,7 @@ export default function (Alpine: TAlpine) {
165165 */
166166 const form = Alpine . reactive ( createForm ( ) ) as Data & Form < Data >
167167
168- syncWithDom ( el , resolveMethod ( method ) , resolveUrl ( url ) , form )
168+ syncWithDom ( Alpine , el , resolveMethod ( method ) , resolveUrl ( url ) , form )
169169
170170 return form
171171 } )
@@ -174,15 +174,15 @@ export default function (Alpine: TAlpine) {
174174/**
175175 * Sync the DOM form with the Precognitive form.
176176 */
177- const syncWithDom = < Data extends Record < string , unknown > > ( el : Node , method : RequestMethod , url : string , form : Form < Data > ) : void => {
177+ const syncWithDom = < Data extends Record < string , unknown > > ( Alpine : TAlpine , el : Node , method : RequestMethod , url : string , form : Form < Data > ) : void => {
178178 if ( ! ( el instanceof Element && el . nodeName === 'FORM' ) ) {
179179 return
180180 }
181181
182182 syncSyntheticMethodInput ( el , method )
183183 syncMethodAttribute ( el , method )
184184 syncActionAttribute ( el , url )
185- addProcessingListener ( el , form )
185+ addProcessingListener ( Alpine , el , form )
186186}
187187
188188/**
@@ -231,4 +231,6 @@ const syncSyntheticMethodInput = (el: Element, method: RequestMethod) => {
231231/**
232232 * Add processing listener.
233233 */
234- const addProcessingListener = < Data extends Record < string , unknown > > ( el : Element , form : Form < Data > ) => el . addEventListener ( 'submit' , ( ) => ( form . processing = true ) )
234+ const addProcessingListener = < Data extends Record < string , unknown > > ( Alpine : TAlpine , el : Element , form : Form < Data > ) => el . addEventListener ( 'submit' , ( ) => {
235+ Alpine . nextTick ( ( ) => form . processing = true )
236+ } )
0 commit comments