In between button not having AJAX applied correctly

Created on 24 October 2023, 8 months ago

Problem/Motivation

When enabling "add in between buttons" and "Use off-canvas instead of modal dialog" with 2 buttons, when I create a new node, the "+" button does not open up the dialog. The first two paragraph options work for me. Also, if I click the paragraph and it is added, the "+" now work.

Steps to reproduce

Currently using:

  • drupal/core: 10.1.5
  • drupal/paragraphs: 1.16.0
  • drupal/paragraphs_features: 2.0.0-beta3
  • drupal/paragraphs_ee: 10.0.2

And I have 2 patches for paragraphs_features

Set your field widget settings to enable "Enable add in between buttons" and "Use off-canvas instead of modal dialog", and try to add a node. The "+" button should not do anything when clicked, but the other buttons, if you allowed, should add the correct paragraph.

Proposed resolution

Diving into paragraphs_ee.admin.js, it looks like for the initial load, paragraphs_ee is using its custom method for attaching AJAX, `bindAjaxLinksWithProgress()`. When it is called it is using `querySelectorAll()` which return a NodeList. bindAjaxLinksWithProgress checks that the element being passed is an Element, and just returns if not. I'm not totally sure why that check was added, but I personally like checking for types like that, so I think that should remain. Which means the call needs to be updated. Just adding a foreach in. Attaching a patch below and it includes calling a warning too. Seems if you are calling `bindAjaxLinksWithProgress()`, you should know its failing.

Also, to note, it seems when the content for the new paragraphs are AJAXed in, the links are being bound by the normal drupal process using `bindAjaxLinks()`

πŸ› Bug report
Status

Fixed

Version

10.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States pingevt

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

Comments & Activities

Production build 0.69.0 2024