Issue #3627475: builder-form.js throws when a component event fires outside the builder form

Closes #3627475. Follow-up to #3467793.

Drupal.behaviors.layoutParagraphsBuilderForm assumed every [data-lpb-id] element is inside the builder form. A Layout Paragraphs widget inside a component dialog is not, so its component events made closest('[data-lpb-form-id]') return null and the behavior threw TypeError: Cannot read properties of null (reading 'querySelector').

  • Return early when the element is not inside a builder form, and only set the label when the close button exists. This is the patch from #3467793-25 by @luisnicg, with a trailing comma for prettier.

Tests:

  • Cypress: builder-form-events.cy.js opens the frontend builder, fires a component event on a [data-lpb-id] element outside the builder form (no error, the button keeps "Close") and one inside it (the button becomes "Cancel"). It fails without the fix with the TypeError above.

Merge request reports

Loading
Loading