Repository navigation
fix(admin): sync form state when editing taxonomy terms - #221
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 924157a The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
The TermFormDialog component wasn't updating form fields when switching between different terms because React's useState only uses initial values on first mount. Add useEffect to sync form state (label, slug, parentId, description) when the term prop changes. Fixes emdash-cms#220
tohaitrieu
force-pushed
the
fix/taxonomy-form-state
branch
from
April 5, 2026 02:43
57ecdba to
1abb04d
Compare
BenjaminPrice
approved these changes
Apr 6, 2026
BenjaminPrice
left a comment
Contributor
There was a problem hiding this comment.
Clean, focused fix — adds a useEffect to sync TermFormDialog form state when the term prop changes, resolving stale fields when switching between taxonomy terms.
Tested scenarios
- Opened the edit dialog for a taxonomy term and confirmed form fields (label, slug, description, parent) populate correctly.
- Switched from one term to another and verified all fields update to reflect the newly selected term.
- Opened a new-term dialog after editing an existing term and confirmed fields reset to empty defaults.
- Verified auto-slug generation re-enables when switching from an existing term to the new-term form.
- Confirmed error state clears when switching between terms.
- Edited a term, saved, then re-opened the dialog to verify persisted values load correctly.
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
JULJERYT
approved these changes
Apr 6, 2026
Contributor
|
great! |
5 tasks
fmhall
pushed a commit
to fmhall/emdash
that referenced
this pull request
Apr 13, 2026
* fix(admin): sync form state when editing taxonomy terms The TermFormDialog component wasn't updating form fields when switching between different terms because React's useState only uses initial values on first mount. Add useEffect to sync form state (label, slug, parentId, description) when the term prop changes. Fixes emdash-cms#220 * chore: add changeset for taxonomy form state fix --------- Co-authored-by: Matt Kane <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes TermFormDialog not updating form fields when switching between different taxonomy terms. The dialog was using
useStatewith initial values from thetermprop, but React only uses initial values on first mount, causing the form to show stale data when editing different terms.Added a
useEffecthook that syncs form state (label, slug, parentId, description) whenever thetermprop changes.Closes #220
Type of change
Checklist
pnpm typecheckpassespnpm --silent lint:json | jq '.diagnostics | length'returns 0pnpm testpasses (or targeted tests for my change)pnpm formathas been run