Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twice rendering the HTML element content with the initial data #5775

Open
mojtaba-khallash opened this issue Aug 28, 2024 · 3 comments
Open

Comments

@mojtaba-khallash
Copy link

mojtaba-khallash commented Aug 28, 2024

Describe the bug

Consider a form contains HTML element, its content will be displayed correctly in normal mode. But if we setup form with initial data, the content of the HTML element will be rendered twice.

Version/Branch
Formiojs version 4.21.2

To Reproduce

  • form schema
var schema = {
  "display": "form",
  "components": [
	{
	  "label": "Version",
	  "key": "version",
	  "type": "textfield"
	},
	{
	  "label": "First Name",
	  "key": "firstName",
	  "type": "textfield"
	},
	{
	  "label": "Last Name",
	  "key": "lastName",
	  "type": "textfield"
	},
	{
	  "label": "HTML",
	  "content": "<h1>hello</h1>",
	  "key": "html",
	  "type": "htmlelement"
	}
  ]
};
  • form setup
Formio.createForm(document.getElementById('formio'), schema).then(function(form) {
  form.submission = {
	data: {
	  version: Formio.version,
	  firstName: 'Joe',
	  lastName: 'Smith'
	}
  }; 
});

Expected behavior
HTML content is expected to be rendered once but twice.

Screenshots

image

@lane-formio
Copy link
Contributor

We actually have a dev actively investigating this issue this week.
For internal reference: FIO-8423

@fuadkhan1996
Copy link

fuadkhan1996 commented Sep 26, 2024

Is there any progress on it? I'm facing the same issue.

@lane-formio
Copy link
Contributor

lane-formio commented Sep 30, 2024

For 4.21.x we had to apply a workaround to resolve this behavior. To fix our own forms we changed the default html tag to "div" (from "p") and had to remove any html from the content that was registering as invalid.

Otherwise, this will be resolved in our 5.x official release. (Should be working in the latest 5.0.0-rc version)

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

No branches or pull requests

3 participants