fix: sync TermFormDialog state when switching between edit targets#239
fix: sync TermFormDialog state when switching between edit targets#239JiayuuWang wants to merge 1 commit intoemdash-cms:mainfrom
Conversation
React's useState only uses the initial value on first mount. When the term prop changes (e.g. user clicks Edit on a different term), the form fields stayed populated with the previously edited term's data. Add a useEffect that resets all form fields whenever the term prop changes, ensuring the dialog always reflects the currently selected term. Fixes emdash-cms#220
|
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
Summary
Fixes #220
When clicking Edit on different taxonomy terms, the form dialog retains data from the previously edited term because
React.useStateonly uses its initial value on first mount — subsequent prop changes don't update state automatically.useEffectinTermFormDialogthat resets all form fields (label,slug,parentId,description,autoSlug,error) whenever thetermprop changesSteps to reproduce the bug
After this fix, step 4 correctly shows Category B's data.
Test plan
🤖 Generated with Claude Code