File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -347,16 +347,27 @@ export default {
347347 const answer = { ... this .answer }
348348 answer .text = value
349349
350- // Dispatched for creation. Marked as synced
351- this .$set (this .answer , ' local' , false )
352- const newAnswer = await this .createAnswer (answer)
350+ // Prevent any queued debounced PATCHes from running while creating
351+ this .queue .pause ()
352+ try {
353+ const newAnswer = await this .createAnswer (answer)
354+ if (! newAnswer || ! newAnswer .id ) {
355+ // Creation failed or response invalid — keep the local input as-is
356+ return
357+ }
353358
354- // Forward changes, but use current answer.text to avoid erasing
355- // any in-between changes while creating the answer
356- newAnswer .text = this .$refs .input .value
357- this .localText = ' '
359+ // Forward changes, but use current input value to avoid erasing
360+ // any in-between changes while creating the answer
361+ const currentText = this .$refs .input ? .value ?? ' '
362+ newAnswer .text = currentText
363+ this .localText = ' '
358364
359- this .$emit (' create-answer' , this .index , newAnswer)
365+ this .$emit (' create-answer' , this .index , newAnswer)
366+ } finally {
367+ // Clear pending update tasks (stale PATCHes) before resuming processing
368+ this .queue .clear ()
369+ this .queue .start ()
370+ }
360371 },
361372
362373 /**
You can’t perform that action at this time.
0 commit comments