Skip to content

fix(renderer): tolerate unknown userData keys and formData without config - #507

Merged
kevinchappell merged 4 commits into
mainfrom
fix/renderer-robustness
Sep 28, 2026
Merged

kevinchappell merged 4 commits into
mainfrom
fix/renderer-robustness

Conversation

@kevinchappell

Copy link
Copy Markdown
Collaborator

What

Two renderer robustness fixes.

renderer.userData setter

  • A key with no matching field used to throw a TypeError and drop every key after it. Such keys are now skipped, with one console warning listing them: formeo: renderer.userData has no field named: ….
  • The setter never throws. Setting null is a no-op, and setting data before render() warns that there's nothing to fill yet.
  • The setter finds the form the same way the getter does.
  • A <select multiple> now takes an array of values. Before, it got the string "x,z".

formData without config

  • Rows and columns without config (what formBuilder2Formeo writes for columns) and radio or checkbox groups without config used to throw, reading width, legend or inline. They now render.
  • A missing children array is treated as empty.
  • Tests use a fixture shaped like the converter's convertData() output.
  • The converter still writes no attrs.type, so hidden and option-group fields don't render as such. That's covered separately in the migration docs.

Refs #123
Refs #229
Refs #212

Testing

  • npm test: 581 pass
  • npm run lint: clean
  • Playwright: 150 passed, 3 skipped. That's one more than main: the new tests/renderer-user-data.spec.js.

…rowing

Assigning saved answers with a key the form no longer has threw a
TypeError and dropped every key after it. Skip such keys, log one
warning listing them, find the form the same way the getter does, and
select every value of an array for a multiple select.

Refs #123
Refs #229
formBuilder2Formeo writes columns with no config, and hand-written
formData often leaves it out, so the renderer threw reading width,
legend or inline. Default config (and children) where the renderer
reads them, and test with data shaped like the converter's output.

Refs #212
…option-wrap className

The userData setter blamed every key as unmatched when no form was
rendered yet; warn once that it was set before render() instead, and
return before touching a nonexistent form. Also strengthen two
renderer.test.js assertions left too loose by earlier fixes: the
option-group-with-no-config test now sets a field className and
checks it lands on the group's wrap, and the formBuilder2Formeo
column-style loop now asserts it actually iterates 3 columns.

Refs #123
Refs #212
Copilot AI lite review requested due to automatic review settings September 28, 2026 09:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Unresolved renderer setter issues remain for collection-property keys and file-input values.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Improves renderer handling of unknown userData keys, multiple-select values, and legacy form data without configuration.

Changes:

  • Adds safer user-data restoration and warnings.
  • Handles missing configuration and children.
  • Adds tests, fixtures, and documentation.
File Description
tests/​renderer-user-data.spec.js Adds browser-level setter coverage.
src/​lib/​js/​renderer/​renderer.test.js Adds renderer regression tests.
src/​lib/​js/​renderer/​index.js Updates user-data handling and config processing.
src/​lib/​js/​renderer/​__fixtures__/​formbuilder2formeo.mjs Adds converter-shaped form data.
src/​lib/​js/​common/​dom.js Safely handles missing field configuration.
docs/​renderer/​renderer.md Documents setter behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/lib/js/renderer/index.js Outdated
}
const unmatched = []
for (const key of keys) {
const fields = form?.elements[key] ?? form?.elements[`${key}[]`]
@kevinchappell

Copy link
Copy Markdown
Collaborator Author

@copilot Fix the code for all comments in this review thread.

When a review comment includes a suggested change, apply the suggestion exactly.

Do not make changes beyond what is described in the linked review thread.

Co-authored-by: kevinchappell <1457540+kevinchappell@users.noreply.github.com>

Copilot AI commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

@copilot Fix the code for all comments in this review thread.

When a review comment includes a suggested change, apply the...

Addressed in e011a36.

@kevinchappell
kevinchappell merged commit 8a35414 into main Sep 28, 2026
@kevinchappell
kevinchappell deleted the fix/renderer-robustness branch September 28, 2026 11:52
@kevinchappell

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 5.9.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants