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.

Issue fork webform-3460381

Command icon 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

geoffreyr created an issue. See original summary.

geoffreyr’s picture

Assigned: geoffreyr » Unassigned
Status: Active » Needs review

MR is in. I should review the existing tests to see if the behaviour is already covered or not.

jrockowitz made their first commit to this issue’s fork.

jrockowitz’s picture

Attached webform replicates the issue.

Let's move the fix into \Drupal\webform\Plugin\WebformElement\PasswordConfirm

jrockowitz’s picture

Version: 6.2.x-dev » 6.3.x-dev
jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.