Problem/Motivation
We've been using the password confirm widget on some forms* but have seen the validation widget consistently emitting JS errors. The error seems to be due to it using Drupal core's Javascript to run the validation, which expects a specific classname to be on the wrapper element that isn't present.
Uncaught TypeError: $confirmInput[0] is undefined passwordCheck http://localhost:8080/core/modules/user/user.js?v=10.2.7:232 jQuery 8 attach http://localhost:8080/core/modules/user/user.js?v=10.2.7:250 attach http://localhost:8080/core/modules/user/user.js?v=10.2.7:66
Referring to https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/user/..., $passwordWidget expects the wrapper to have classname js-form-type-password-confirm. I've seen js-webform-type-password-confirm, but never js-form-type-password-confirm.
Steps to reproduce
- Create a webform with the password confirm widget
- Load the form in the browser
- Enter one character inside the first password field
* We're deliberately not saving submissions to our database, and anyone else using the Password Confirm widget should be taking similar precautions.
Proposed resolution
Add the classname js-form-type-password-confirm to the wrapper element for Password Confirm webform widgets.
Remaining tasks
- Add the classname
- Test the fix
User interface changes
None.
API changes
None.
Data model changes
None.
Issue fork webform-3460381
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
geoffreyr commentedMR is in. I should review the existing tests to see if the behaviour is already covered or not.
Comment #5
jrockowitz commentedAttached webform replicates the issue.
Let's move the fix into \Drupal\webform\Plugin\WebformElement\PasswordConfirm
Comment #6
jrockowitz commentedComment #7
jrockowitz commented