You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: TermFormDialog doesn't update form state when editing different terms #220
When editing taxonomy terms in the admin UI, the form fields don't update when switching between different terms. The form continues to show data from the previously edited term.
Steps to Reproduce
Go to Taxonomies > Categories
Click Edit on "Category A"
Close the dialog without saving
Click Edit on "Category B"
Expected: Form shows Category B's data (label, slug, description)
Actual: Form still shows Category A's data
Root Cause
In packages/admin/src/components/TaxonomyManager.tsx, the TermFormDialog component uses useState with initial values from the term prop:
React's useState only uses the initial value on first mount. When the term prop changes, the state is not updated.
Proposed Fix
Add a useEffect to sync form state when the term prop changes:
// Sync form state when term prop changes (for edit mode)React.useEffect(()=>{setLabel(term?.label||"");setSlug(term?.slug||"");setParentId(term?.parentId||"");setDescription(term?.description||"");setAutoSlug(!term);setError(null);},[term]);
I have a fix ready and can submit a PR if this approach is acceptable.
Activity
fix(admin): sync form state when editing taxonomy terms
fix: sync TermFormDialog state when switching between edit targets
fix(admin): sync form state when editing taxonomy terms
fix(admin): sync TermFormDialog state on term change and add back but…
fix(admin): sync form state when editing taxonomy terms (#221)
fix(admin): sync form state when editing taxonomy terms (emdash-cms#221)