Password confirm widget not working with JS validation code

Created on 10 July 2024, 6 months ago

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

  1. Create a webform with the password confirm widget
  2. Load the form in the browser
  3. 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

  1. Add the classname
  2. Test the fix

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

6.2

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia geoffreyr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024