Form template composer fields lose their newlines in the edit preview

AI-generated summary

ScaryLarryGames1 reports a bug in form templates where multiline composer fields lose their newlines in the edit preview, rendering as a single run-on line with broken formatting. The root cause is identified in form-template-field/composer.gjs: the composer field is mirrored into a hidden <input type="text"> for native validation. Per HTML standards, assigning a value to a text input strips CR/LF characters, so newlines are removed before the preview cooks the reply. The saved post remains correct because the final save reads directly from the editor component.

A temporary workaround involves changing the hidden inputs to type="hidden" (which preserves newlines) and dispatching an input event to rebuild the preview. However, the reporter notes that this bypasses native required validation, suggesting that a core fix should use a visually hidden <textarea> instead.

Tannerabread confirms that the suggested textarea approach was implemented and the fix has been merged via PR #43043. Meta-bot subsequently marks the issue as fixed, stating that edit previews now correctly preserve line breaks in form-template fields.

Editing a post that uses a form template, the composer preview renders any multiline composer field as one run-on line: headings glued to the sentence after them, lists and BBCode as literal text. The saved post cooks correctly — only the preview is wrong.

Cause: form-template-field/composer.gjs mirrors each composer field into a hidden <input type="text"> for native validation:

<input id={{this.validationInputId}} type="text" name={{@id}} value={{this.composerValue}} ... class="form-template-field__composer-hidden-input" />

The composer reply — which is what the preview cooks — is assembled from those inputs. Per the HTML value-sanitisation rules, a type="text" input strips CR/LF on assignment, so every newline in the field value is gone by the time the preview sees it. Saving reads the editor itself, which is why the stored raw is unaffected.

Repro (2026.9.0-latest): any form template with a composer field → enter text containing blank lines (e.g. a ## heading, a paragraph, a list) → open edit on the saved post → the preview shows it flattened into a single line while the post itself renders fine.

Workaround we are running as a theme: flip the hidden inputs to type="hidden" (which preserves newlines on assignment), repair the already-flattened value from the field editor, and dispatch one input event so the reply rebuilds. That fully restores the preview.

Note for a core fix: type="hidden" skips native required constraint validation, so the stand-in control probably wants to be a visually hidden <textarea> rather than a text input.

2 Likes

Hi @ScaryLarryGames1, thank you for reporting this.

The fix ended up being what you suggested with the textarea and has just been merged. Give it a few to go through CI/CD and make it to the latest branch.

2 Likes

Fixed in #43043. The edit preview now preserves line breaks in form-template fields.