The ticket preview component started behaving unstably after a recent PR when switching quickly between codes. We need to find the causes from the diff and describe what exactly is broken.
ticketCode through props.ticketCode, a new fetchTicketPreview(code) request must be started.ticketCode, even if the old request finished later than the new one.ticketCode is not considered in this task: assume the parent always passes a non-empty code.fetchTicketPreview artificially delays responses differently for different codes.ticketCode = "A-100";ticketCode = "B-200".currentCode.value = 'A-100'
setTimeout(() => {
currentCode.value = 'B-200'
}, 10)
B-200, the panel should quickly move to a loading state without content from A-100.B-200 should remain on the screen.ticketCode.3.5.13, Composition API, <script setup>5.8.3fetchTicketPreview(code): Promise<{ code: string; subject: string; owner: string }>A-100 — 120ms, for B-200 — 40ms, for other codes — 80msticketCode many times in a row without waiting for the previous request to finishUse line comments to explain the problem, its impact, the fix and how to test it.