Skip to content

fix(admin): sync TermFormDialog state on term change; add back button to Security & AllowedDomains settings#259

Open
pangerlkr wants to merge 10 commits intoemdash-cms:mainfrom
pangerlkr:fix/taxonomy-form-state-and-settings-back-button
Open

fix(admin): sync TermFormDialog state on term change; add back button to Security & AllowedDomains settings#259
pangerlkr wants to merge 10 commits intoemdash-cms:mainfrom
pangerlkr:fix/taxonomy-form-state-and-settings-back-button

Conversation

@pangerlkr
Copy link
Copy Markdown
Contributor

Summary

This PR contains two independent bug fixes for the admin panel.


Fix 1: TermFormDialog stale state when editing different terms

Problem: TermFormDialog initialized all form fields with useState(term?.label || "") etc. — but React's useState only runs once on mount. When the term prop changed (e.g., clicking Edit on a second taxonomy term), the dialog would show the stale data from the first term.

Fix: Added a useEffect that watches the term prop and resets all form fields (label, slug, parentId, description, autoSlug, error) whenever it changes.

// Sync form state when term prop changes (e.g. when editing a different term)
React.useEffect(() => {
  setLabel(term?.label || "");
  setSlug(term?.slug || "");
  setParentId(term?.parentId || "");
  setDescription(term?.description || "");
  setAutoSlug(!term);
  setError(null);
}, [term]);

Fix 2: Missing back button on Security Settings & Self-Signup Domains settings pages

Problem: SecuritySettings and AllowedDomainsSettings had no back navigation in their page header, unlike other settings sub-pages (e.g. GeneralSettings). Users had to use the browser back button or sidebar to return to the main settings list.

Fix: Added an ArrowLeft icon button linking to /settings in the page <h1> header row of both components, consistent with the pattern used across the rest of the settings pages.

<div className="flex items-center gap-3">
  <Link to="/settings">
    <Button variant="ghost" shape="square" size="sm" aria-label="Back to Settings">
      <ArrowLeft className="h-4 w-4" />
    </Button>
  </Link>
  <h1 className="text-2xl font-bold">Security Settings</h1>
</div>

Files Changed

  • packages/admin/src/components/TaxonomyManager.tsx — add useEffect to sync form state
  • packages/admin/src/components/settings/SecuritySettings.tsx — add back button to page header
  • packages/admin/src/components/settings/AllowedDomainsSettings.tsx — add back button to page header

Copilot AI and others added 4 commits April 4, 2026 08:03
Agent-Logs-Url: https://github.com/pangerlkr/emdash/sessions/0b446ce9-176a-438b-84b2-b1d5d147f717

Co-authored-by: pangerlkr <73515951+pangerlkr@users.noreply.github.com>
…ton to SecuritySettings/AllowedDomainsSettings

Fixes emdash-cms#220: TermFormDialog used useState with initial props but never synced
when the `term` prop changed (switching between different terms). Added a
useEffect to reset all form fields whenever the term prop changes.

Fixes emdash-cms#256: SecuritySettings and AllowedDomainsSettings pages were missing
the back arrow button in their page headers, unlike all other settings pages.
Added a back-to-settings link with ArrowLeft icon to the main return JSX
header of both components, consistent with how other settings pages handle it.
Copilot AI review requested due to automatic review settings April 5, 2026 04:29
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 5, 2026

⚠️ No Changeset found

Latest commit: efc5bdd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


1 out of 2 committers have signed the CLA.
✅ (pangerlkr)[https://github.com/pangerlkr]
❌ @Copilot
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes two admin-panel UX/state bugs and adds a new PRD document to the repo.

Changes:

  • Sync TermFormDialog local form state when the term prop changes to avoid stale values when editing multiple terms.
  • Add an in-header “back to settings” button on the Security and Self‑Signup Domains settings pages.
  • Add PRD.md describing EmDash product requirements and architecture.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
PRD.md Adds a comprehensive Product Requirements Document (new documentation artifact).
packages/admin/src/components/TaxonomyManager.tsx Resets term-edit form state via useEffect when switching the edited term.
packages/admin/src/components/settings/SecuritySettings.tsx Adds a header back-navigation button to /settings.
packages/admin/src/components/settings/AllowedDomainsSettings.tsx Adds a header back-navigation button to /settings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +150 to +157
<div className="flex items-center gap-3">
<Link to="/settings">
<Button variant="ghost" shape="square" size="sm" aria-label="Back to Settings">
<ArrowLeft className="h-4 w-4" />
</Button>
</Link>
<h1 className="text-2xl font-bold">Security Settings</h1>
</div>
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new back button is only rendered in the main (non-loading / non-error) return path. In the loading and error early-returns, the header is still just an

with no back navigation, which reintroduces the same usability issue in those states. Consider extracting a shared header component/JSX and using it in all return branches (loading, external-auth info, error, and success) so navigation stays consistent.

Copilot uses AI. Check for mistakes.
Comment on lines +221 to +228
<div className="flex items-center gap-3">
<Link to="/settings">
<Button variant="ghost" shape="square" size="sm" aria-label="Back to Settings">
<ArrowLeft className="h-4 w-4" />
</Button>
</Link>
<h1 className="text-2xl font-bold">Self-Signup Domains</h1>
</div>
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The back button is only present in the final render branch. The loading and error early-returns still render only an

(no back navigation), so users can still get stuck without an in-page way to return to /settings in those states. Consider reusing the same header JSX across all branches (loading, external-auth info, error, success).

Copilot uses AI. Check for mistakes.
PRD.md Outdated
Comment on lines +1 to +8
# EmDash — Product Requirements Document

## 1. Executive Summary

EmDash is a full-stack TypeScript CMS built on Astro and designed to run on Cloudflare or Node.js. It provides the familiar content-management capabilities of WordPress—posts, pages, media, taxonomies, menus, plugins, users—reimplemented with a modern, type-safe, serverless-first architecture. The product stores its schema in the database rather than in code, runs plugins in isolated Worker sandboxes, and ships with a built-in MCP server so AI agents can interact with site content natively.

---

Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds a large new PRD document, but the PR title/description describe only two small admin UI bug fixes. Either update the PR description to include the PRD addition and rationale, or split the PRD.md change into a separate PR to keep review scope focused.

Copilot uses AI. Check for mistakes.
@pangerlkr
Copy link
Copy Markdown
Contributor Author

Note: Fix 1 (TermFormDialog stale state) also addresses issue #220. This PR's approach can be compared against the implementations in #239 and #221, which tackle the same underlying problem. PR #259 combines both fixes (stale form state + missing back button) making it the most comprehensive submission of the three.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 5, 2026

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@259

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@259

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@259

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@259

emdash

npm i https://pkg.pr.new/emdash@259

create-emdash

npm i https://pkg.pr.new/create-emdash@259

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@259

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@259

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@259

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@259

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@259

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@259

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@259

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@259

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@259

commit: 2d671de

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@barckcode
Copy link
Copy Markdown
Contributor

Hey! Regarding the TermFormDialog fix in this PR — PR #221 seems to address the same stale state issue and already has maintainer approval from @ascorbic. Might be worth checking if that one covers the form state part before investing more time here.

@emdashbot
Copy link
Copy Markdown
Contributor

emdashbot bot commented Apr 8, 2026

Could not push formatting changes to this fork. The contributor may have "Allow edits by maintainers" disabled.

Please run the formatter locally:

pnpm format

@pangerlkr
Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Apr 8, 2026
@pangerlkr
Copy link
Copy Markdown
Contributor Author

I noticed there are related issues and PRs in this repository that overlap with the fixes in this PR. This PR addresses stale state in TermFormDialog and missing back buttons in Security & AllowedDomains settings — both of which may be referenced in open issues. If maintainers are tracking these under separate issues, feel free to link them here for better traceability. Happy to rebase or address any review feedback!

@emdashbot
Copy link
Copy Markdown
Contributor

emdashbot bot commented Apr 9, 2026

Could not push formatting changes to this fork. The contributor may have "Allow edits by maintainers" disabled.

Please run the formatter locally:

pnpm format

@pangerlkr
Copy link
Copy Markdown
Contributor Author

recheck

@pangerlkr
Copy link
Copy Markdown
Contributor Author

Workflow Status & CLA Fix Notes

✅ Resolved

  • Merge conflict in packages/admin/src/components/TaxonomyManager.tsx — resolved by keeping the PR branch's more descriptive comment (e.g. when editing a different term)
  • "Allow edits by maintainers" — enabled so emdashbot can push formatting fixes directly
  • Auto Format check — now passing ✅

⚠️ CLA Check Failing — Root Cause

The CLA Assistant is failing because commit 4ac7dce (Add PRD.md) was co-authored by the GitHub Copilot coding agent (@copilot). The CLA workflow's allowlist in .github/workflows/cla.yml currently only includes:

allowlist: dependabot[bot],emdashbot[bot]

Copilot's bot account (copilot-swe-agent[bot]) is not in the allowlist, so the CLA bot requires it to sign — which is impossible for an automated agent.

🔧 Fix Required from Maintainers

A maintainer needs to update .github/workflows/cla.yml line ~30 to add copilot-swe-agent[bot] to the allowlist:

allowlist: dependabot[bot],emdashbot[bot],copilot-swe-agent[bot]

Once that's updated and the CLA workflow re-runs, the CLAssistant check should pass.

⏳ Workflows Awaiting Approval

The 5 workflows (Browser Tests, E2E Tests, Lint, Smoke Tests, Tests, Typecheck, Validate Plugins) are pending because they require maintainer approval for first-time contributors — nothing the PR author can action on their end.

@pangerlkr
Copy link
Copy Markdown
Contributor Author

recheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants