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

novalidate={true} fails silently #2399

Open
fongandrew opened this issue Jan 6, 2025 · 2 comments
Open

novalidate={true} fails silently #2399

fongandrew opened this issue Jan 6, 2025 · 2 comments

Comments

@fongandrew
Copy link

Describe the bug

There are three ways to enable the novalidate behavior on a form:

  1. <form noValidate={true}> (this sets the property)
  2. <form novalidate={true}> (this sets an attribute to true)
  3. <form novalidate> (this sets an attribute via the template)

1 and 3 work as expected and disable form validation. 2 does not.

Your Example Website or App

https://playground.solidjs.com/anonymous/150a858a-e788-44db-95c5-f45abd7cb9ea

Steps to Reproduce the Bug or Issue

Add novalidate={true} to a form.

<form novalidate={true} onSubmit={console.log}>
    <input id="foo" required />
    <input type="submit" />
</form>

Validation will still occur because the form is created without novalidate attribute. Solid will attempt to set the .novalidate property but this is not valid (it should be .noValidate).

Expected behavior

I'd expect one of the following to happen:

  • Solid sets the novalidate attribute: <form novalidate> or <form novalidate="">
  • Solid translates the novalidate attribute into the noValidate property
  • Solid complains at runtime that setting a boolean attribute for novalidate isn't allowed.
  • The Solid JSX TypeScript type defs refuse to allow this.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 131.0

Additional context

No response

@fongandrew
Copy link
Author

I'm guessing we probably need to just update things here so novalidate aliases to noValidate the way formnovalidate does? https://github.com/ryansolid/dom-expressions/blob/828f9e9cef5e0482d904ae4f6ec1069dba378a44/packages/dom-expressions/src/constants.js#L57-L61

@ryansolid
Copy link
Member

Yeah I suspect this may be the result of missing property addition and maybe some newer boolean logic up against each other. I would have expected all of the above to work and only novalidate={false} to be weird if it were boolean attribute and not identified. So there is some gap that has been introduced somewhere perhaps since our default is to make things attributes so I'd expect novalidate="true" to be the output if it wasn't being handled as a property.

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

2 participants