fix(ui): prevent autosave from reverting recently edited fields - #17697
fix(ui): prevent autosave from reverting recently edited fields#17697lucasvass1 wants to merge 1 commit into
Conversation
… remounting relationship/upload list drawers Switching to a different field while a previous autosave request was still in flight cleared that field's modified protection, so a stale response could overwrite the newer local edit. Track a per-field last-modified timestamp and compare it against when each request was sent, so a response is only accepted if no local edit happened after it was dispatched. Also preserve the value/initialValue reference for unmodified fields when the incoming server value is content-identical, since object/array-shaped values (e.g. relationship and upload fields) otherwise get a new reference on every autosave merge, causing their list drawers to needlessly recompute filter options and remount.
|
@lucasvass1 I think this may already be fixed by #17455. Would you mind testing that PR to confirm? |
|
@jacobsfletch oi, tudo bem? Analisei a PR #17455 e ela corrige um dos erros que corrigi, porém não o segundo. Ela resolve a sobrescrita de campo por resposta de autosave obsoleta (digitar em um campo, trocar pra outro antes do autosave anterior terminar, e o valor reverter). Mas não resolve a media library recarregando/piscando durante o autosave. Isso acontece porque, mesmo quando um campo relationship/upload não foi editado, o merge da PR aceita o valor vindo do servidor como se fosse novo — e como esse valor chega recém-serializado a cada resposta, ele tem uma referência diferente mesmo com o mesmo conteúdo. Isso faz o drawer da lista recalcular e remontar sem necessidade. Testei isso na prática, rodando meus testes contra o branch da #17455: o teste da sobrescrita passa, mas o teste do remount do drawer falha. |
Fixes #17676
Summary
modifiedAttimestamp and comparing it against when each request was sent — a response is only accepted for a field if no local edit happened to it after that specific request was dispatched.useListDrawerrecomputing and remounting the open drawer. Fixed by preserving the existing reference inmergeServerFormStatewhen the incoming value is deeply equal to the current one.Test plan
mergeServerFormStatecovering reference preservation for content-identical valuestest/form-statestill pass (no regression to the "don't overwrite a field being actively edited" behavior)pnpm run build:coreand lint pass