Problem/Motivation

The Unlock dialog does not go away after clicking Unlock. There is an error in the Javascript console:

Uncaught TypeError: Cannot read properties of null (reading 'querySelectorAll')
    at HTMLDivElement.click (ui.js?rqwold:41:23)
    at HTMLButtonElement.<anonymous> (dialog.js:529:12)
    at HTMLButtonElement.dispatch (jquery.min.js?v=3.6.3:2:43336)
    at y.handle (jquery.min.js?v=3.6.3:2:41320)

Steps to reproduce

  • Install stock Drupal 9.5.4 or 10.0.4. Claro is the installed admin theme.
  • Configure the Title field of the Article content type to be locked
  • Edit an article
  • Click the Unlock field button

Expected behavior

Field should be unlocked, dialog dismissed.

Actual behavior

Although the field appears to be unlocked (if your screen is big enough to see behind the dialog), the dialog persists. Clicking the Unlock button again on the dialog does not dismiss the dialog, plus there is a Javascript error:

Uncaught TypeError: Cannot read properties of null (reading 'querySelectorAll')
    at HTMLDivElement.click (ui.js?rqwold:41:23)
    at HTMLButtonElement.<anonymous> (dialog.js:529:12)
    at HTMLButtonElement.dispatch (jquery.min.js?v=3.6.3:2:43336)
    at y.handle (jquery.min.js?v=3.6.3:2:41320)

Proposed resolution

The Drupal behavior that adds the Javascript functionality is being run multiple times, adding mutiple click event listeners to the unlock button, producing the unexpected results. We should use core/once to handle this correctly.

Remaining tasks

Patch.

User interface changes

None.

API changes

None.

Data model changes

None.

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

m4olivei created an issue. See original summary.

m4olivei’s picture

Assigned: Unassigned » m4olivei

m4olivei’s picture

Assigned: m4olivei » Unassigned
Status: Active » Needs review

Opened a merge request, which:

  • Uses core/once library to ensure we only assign a single click handler per field
  • Updates core_version_requirement to require 9.2, b/c that is when the core/once library was introduced

I've tested on Drupal 9.3 w/ Seven, Drupal 9.4 w/ Claro and Drupal 10 w/ Claro. Looking good.

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

  • e0ipso committed 9bee0fa7 on 1.x authored by m4olivei
    Issue #3345580 by m4olivei: Unlock dialog does not go away on Claro / 9....
e0ipso’s picture

Status: Needs review » Fixed

This is great! Thank you very much!

Status: Fixed » Closed (fixed)

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