plugin-forms: textarea in FormEmbed renders with whitespace as its initial value
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 88/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- frontend
Research direction
Read packages/plugins/forms/src/astro/FormEmbed.astro, especially the textarea markup around lines 127–129. Check how the default value is placed between the tags and verify the rendered content when defaultValue is unset. Done means the empty field renders with no whitespace value while a supplied default remains intact.
Written by the indexing model from the issue text.
Description
Description
The <textarea> rendered by FormEmbed.astro in @emdash-cms/plugin-forms is not empty when the field has no default value. It contains the newline and indentation from the component source (8 tabs + newline + 7 tabs, 16 characters after the browser drops the leading newline).
As a result:
- The caret starts on the second line, after the indentation, when a visitor focuses the field.
- Browser validation for
required/minlengthtreats the field as filled, so an untouched textarea passes client-side validation. The server trims the value before validating, so empty data is not saved, but the visitor gets a server-side error instead of the browser's inline message.
Expected: the textarea is empty when defaultValue is unset.
Cause: in packages/plugins/forms/src/astro/FormEmbed.astro (lines 127-129 on main), the expression sits on its own indented line between the tags:
>
{field.defaultValue || ""}
</textarea>
Astro keeps whitespace inside <textarea> as-is, so the indentation becomes the value. Putting the expression on the same line as the tags fixes it:
>{field.defaultValue || ""}</textarea>
We have applied this one-line change as a local patch (pnpm patch) since 0.2.4, and it still applies cleanly to 0.2.9. Happy to open a PR with a test if that helps.
Steps to reproduce
- Install
@emdash-cms/plugin-formsand create a form with atextareafield that has nodefaultValueandrequired: true. - Embed the form on a page with the plugin's
FormEmbedcomponent. - Open the page and click into the textarea: the caret starts on line 2, after the indentation.
- Submit without typing anything: the browser's
requiredcheck passes.
Rendering FormEmbed.astro's textarea markup with the Astro Container API (astro 7.3.5) gives this content between <textarea ...> and </textarea>:
"\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t"
Environment
- emdash version: 1.1.0
- @emdash-cms/plugin-forms: 0.2.9 (also reproduced on 0.2.4)
- astro: 7.3.5
- Node.js version: 22.23.2
- Runtime: Cloudflare Workers
- OS: macOS
Screenshots
Logs / error output
- Dominant language
- TypeScript
- Stars
- 13.4k
- Forks
- 1.3k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 576
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from emdash-cms/emdash
-
bot:bug bot:needs-attention
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
emdash-cms/emdash#4110 · 3 comments ·
Maintainers usually reply within 1 day
-
bot:bug bot:needs-attention bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
emdash-cms/emdash#3992 · 2 comments ·
Maintainers usually reply within 1 day
-
bot:bug bot:needs-attention
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
emdash-cms/emdash#3972 · 2 comments ·
Maintainers usually reply within 1 day
-
bot:needs-attention bot:task
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
emdash-cms/emdash#3821 · 1 comment ·
Maintainers usually reply within 1 day
-
area/auth area/cloudflare bot:awaiting-approval bot:bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
emdash-cms/emdash#3702 · 1 comment ·
Maintainers usually reply within 1 day
All issues in emdash-cms/emdash
Similar issues
-
area: repo priority: P2 type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
appandflow/stim#4107 · 1 comment ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 1-3 hours Newbie friendliness 60/100
lingdojo/kana-dojo#32859 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
github/gh-aw-firewall#10364 ·
Maintainers usually reply within 1 day
-
Merge the duplicate kaffir_corn record into sorghumPossibly taken @Crypto-Shroom claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Crypto-Shroom/Bird-Feed-Calculator#322 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
drizzle-team/drizzle-orm#6552 ·
Maintainers usually reply within 2 days