AJAX Dialog API changes the behaviour of regular Dialog API

Created on 21 November 2023, 7 months 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 about 8 hours 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.69.0 2024