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

reportValidity does not work if an sl-input is initially present but subsequently removed. #1703

Closed
straversi opened this issue Nov 3, 2023 · 3 comments · Fixed by #1708
Closed
Labels
bug Things that aren't working right in the library.

Comments

@straversi
Copy link
Contributor

straversi commented Nov 3, 2023

Describe the bug

reportValidity does not work if an sl-input is initially present but subsequently removed.

To Reproduce / Demo

https://codepen.io/straversi/pen/yLZaExo

  1. When the codepen loads, click reportValidity, which calls reportValidity on the form. The form correctly complains "please fill the name field out"
  2. Click the "toggle name" button, which removes the "name" sl-input
  3. Click reportValidity again. It incorrectly does not complain about the empty "comment" sl-input.

Notes

If you swap all the <sl-input>s for <input>s, this problem doesn't happen.

Browser / OS

  • OS: [e.g. Mac]
  • Browser: [e.g. Arc (Chromium)]
  • Browser version: [e.g. Chromium 118]
@straversi straversi added the bug Things that aren't working right in the library. label Nov 3, 2023
@KonnorRogers
Copy link
Collaborator

Thanks for reporting this. I can reproduce the issue. I think I found the issue. Will have a PR up soon that fixes this.

@straversi
Copy link
Contributor Author

You rock, thank you very much! ❤️

@KonnorRogers
Copy link
Collaborator

❤️ anytime! I also snuck in the ability to call form.checkValidity() using Shoelace's custom form handler! Hopefully it fixes it for you! Wasn't easy to track down!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things that aren't working right in the library.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants