Skip to content

fix(import): keep the content a compound submit button wraps - #571

Open
tommy230 wants to merge 1 commit into
CoreBunch:mainfrom
tommy230:fix/import-compound-submit-button
Open

tommy230 wants to merge 1 commit into
CoreBunch:mainfrom
tommy230:fix/import-compound-submit-button

Conversation

@tommy230

@tommy230 tommy230 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A submit button that carries an icon instead of text loses the icon on HTML import. A newsletter form whose submit is an arrow drawn as an inline <svg>, a search box whose submit is an icon-font <i>, or a form whose submit is an <img> all import as base.submit with only the 'Submit' fallback label, and the published page shows that word where the icon was.

<!-- source -->
<form><button type="submit"><svg viewBox="0 0 13 12"><path d="M7.2 11.7 12.2 6.7"/></svg></button></form>

<!-- published today -->
<form><button type="submit">Submit</button></form>

This is the case #476 deliberately left out. base.submit in src/modules/base/forms/index.ts is a leaf whose only content is the label prop, so the button rule in src/core/htmlImport/rules.ts does not recurse into submit buttons and submitLabel() falls back to 'Submit'. The comment there notes that lifting this needs base.submit to accept children; this change does that.

The fix:

  • base.submit accepts children and renders them when it has any, falling back to label only when it has none. The rule lives in src/modules/base/forms/content.ts and is shared by the publisher render and the canvas preview, the same shape base.link uses.
  • The importer recurses into submit buttons with element children, so an inline <svg>, an icon-font <i>, or an <img> survives as child nodes. Text-only submits still import as a childless base.submit with their label, and <input type="submit"> is unchanged.
  • Submit buttons stay base.submit rather than becoming a container, so core/forms still finds the form's submit control by module id.

Trade-off: the Form Settings panel and the form snapshot still read the submit's label prop, so an icon-only submit shows as "Submit" there even though the canvas and the published page show the icon. That is cosmetic and left alone here.

Overlaps with #575 on adjacent docs/features/html-import.md bullets; whichever lands second gets a small rebase.

Verification

  • bun run build
  • bun run lint
  • bun test: 7061 pass, 0 fail
  • Docker/deployment check, if relevant: not relevant

New tests in src/__tests__/htmlImport/submitButtonChildren.test.ts: 6 of 8 fail on main and pass with this change; the two that pass either way cover the unchanged text-only and label-fallback cases. The existing structurePreservation test that pinned the old label-only behaviour now asserts the children are kept.

Checklist

  • Tests cover behavior changes.
  • Docs were updated when behavior, config, deployment, or public surfaces changed. (docs/features/html-import.md: the button row and the "Button-like elements keep what they wrap" note; docs/features/modules.md and docs/reference/module-engine.md.)
  • No compatibility shim was added for old pre-release behavior.
  • No secrets, local databases, uploads, or generated artifacts are included.

🤖 Generated with Claude Code

base.submit was a leaf whose only content was the label string, with a
'Submit' fallback for buttons with no text. Submit buttons that carry an
icon instead of text (an inline svg, an icon-font <i>, an <img>) lost the
icon on import and published as the literal word "Submit".

base.submit now accepts children and renders them when it has any, falling
back to the label when it has none (the base.link contract, shared between
the publisher render and the canvas via forms/content.ts). The importer
recurses into submit buttons with element children instead of flattening
them to a label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tommy230
tommy230 force-pushed the fix/import-compound-submit-button branch from 77ee803 to 1eea45a Compare September 29, 2026 00:02
@tommy230
tommy230 marked this pull request as ready for review September 29, 2026 04:47

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant