Repository navigation
fix(admin): clear optional URL fields as null instead of empty string - #4076
Conversation
🦋 Changeset detectedLatest commit: 21b993b The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 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 |
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://bot-fix-4075.try.emdashcms.com, https://bot-fix-4075-emdash-playground.emdash-cms.workers.dev (commit 21b993b)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-test
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-loader
@emdash-cms/registry-moderation
@emdash-cms/registry-verification
upgrade-emdash
@emdash-cms/sandbox-workerd
@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-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
This is the right fix for the right problem. UrlFieldEditor was emitting an empty string for a cleared optional URL, and the server rejects empty strings as invalid URLs. The change mirrors the existing number-field behavior: empty the input and the editor sends null. I checked ContentEditor.tsx, the new regression test, the changeset, isValidUrl / hasInvalidUrls, and the surrounding field editors. The diff is minimal, the changeset is clear and written for package consumers, and no AGENTS.md conventions (i18n, RTL-safe Tailwind, SQL safety, etc.) are violated.
Headline: the fix is correct. I have one low-priority suggestion to avoid spuriously dirtying a form when an already-empty URL input is blurred.
| if (val !== e.target.value) onChange(val); | ||
| if (!val) { | ||
| setError(null); | ||
| onChange(null); |
There was a problem hiding this comment.
[suggestion] The blur handler now calls onChange(null) whenever the trimmed value is empty, even if the input was already empty and the user made no edit. That spuriously marks the form dirty and adds an explicit null to the save payload.
The onChange callback already emits null as soon as the input is emptied, so the blur fallback only needs to handle whitespace-only input. Guard the call so it only fires when there is actually something to clear:
| onChange(null); | |
| if (!val) { | |
| setError(null); | |
| if (e.target.value) onChange(null); | |
| return; | |
| } |
CompletedRevise candidate PR for issue #4075: optional URL field clearing fails admin save.
Outcome: Revised the candidate fix for #4075. The original change correctly made
Verification:
I also inspected the failing CI checks from the previous candidate. The Files changed: Mode: revise View live dashboard · Run: |
…#4075) EmDash-Run: 72d92491-eca9-4778-a84c-43c95d1428c2
f904004 to
1fef04d
Compare
Timed outRevise bot/fix-4075 after CI reports failing Tests and Browser Tests. Investigate local failures in the admin ContentEditor test and URL schema/validation behavior, then update the fix to make the suite green.
Outcome: The run stopped at its execution deadline before it could provide a checkpoint summary. The conversation and workspace are saved. I'll continue from this checkpoint automatically in about 2 minutes (attempt 1 of 2). Mode: revise View live dashboard · Run: |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
docs | 21b993b | Oct 12 2026, 09:54 AM |
What does this PR do?
Optional
urlfields in the admin could not be cleared once they had a value, becauseUrlFieldEditorsent""toonChangeand the server-side schema rejects empty strings as invalid URLs.Changes:
UrlFieldEditornow emitsnullwhen the input is emptied (onChange) and when a whitespace-only value is blurred and trimmed away (handleBlur).ContentEditor.test.tsxthat verifies clearing an optional URL field saveswebsite: null.This matches the existing number-field fix and keeps non-required URL fields nullable as intended.
Closes #4075.
Try the candidate against your own site with the preview build:
Opened automatically by emdashbot. A maintainer must review before merge.
Type of change
Your connection to this change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.AI assistance disclosure
Screenshots / test output