AJAX Dialog API changes the behaviour of regular Dialog API

Created on 21 November 2023, about 1 year ago

Problem/Motivation

The AJAX Dialog API conflicts with the regular Dialog API and causes it to behave differently when both are included on a page.

Steps to reproduce

Create a node which contains a dialog which uses the Dialog API as documented here :

<p>
    <a id="test-dialog">open modal</a>
</p>
<div id="modal-content">
    modal content
</div>

...and attach the JavaScript:

const dialogLink = document.getElementById('test-dialog');
dialogLink.addEventListener("click", (e) => {
  const content = document.getElementById('modal-content');
  Drupal.dialog(content).showModal();
});

...and attach the core/drupal.dialog library.

The button works as expected and can be opened and closed and opened again any number of times.

Now attach core/drupal.dialog.ajax as well. Now the button opens the first time, but won't open a second time after closing.

Proposed resolution

Either document that these libraries aren't meant to be used together, or (preferably) fix their behaviour so they do.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

10.1

Component
Javascript 

Last updated 3 days ago

Created by

🇳🇿New Zealand fraserthompson Dunedin, New Zealand

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

Comments & Activities

Production build 0.71.5 2024