fix(edit-pages): resolve custom field display race condition

The init watcher destructured currentType/currentStructure before
setting selectedTypeId, so the values were stale (null). This caused
refreshCustomFieldInputs to receive null structure → empty definitions,
permanently wiping custom field display on piece and component edit pages.

Read selectedType.value / selectedTypeStructure.value after setting the
ID so the computed is already updated. Also remove the guard on the
piece selectedType watcher that prevented recovery.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-02-09 16:47:54 +01:00
parent 9f7dd12b34
commit 7c44778f25
2 changed files with 8 additions and 5 deletions

View File

@@ -803,7 +803,9 @@ watch(
void ensureConstructeurs(editionForm.constructeurIds)
}
refreshCustomFieldInputs(currentStructure, currentComponent.customFieldValues)
// After setting selectedTypeId, read selectedTypeStructure.value (now updated) instead of
// the stale destructured currentStructure which was captured before the ID change.
refreshCustomFieldInputs(selectedTypeStructure.value ?? currentStructure, currentComponent.customFieldValues)
initialized = true
},