diff -ruN a/ief_popup.libraries.yml b/ief_popup.libraries.yml --- a/ief_popup.libraries.yml 2024-10-12 08:46:40.000000000 +0200 +++ b/ief_popup.libraries.yml 2026-10-13 11:52:54.787253886 +0200 @@ -9,3 +9,4 @@ - core/jquery - core/drupal - core/drupal.dialog + - core/drupal.dialog.ajax diff -ruN a/js/ief_popup.js b/js/ief_popup.js --- a/js/ief_popup.js 2024-10-12 08:46:40.000000000 +0200 +++ b/js/ief_popup.js 2026-10-13 11:52:54.787253886 +0200 @@ -2,6 +2,31 @@ //$("body").append("
"); + /* + * The popup only mimics the jQuery UI dialog markup (.ui-dialog-content), + * it is never initialized with .dialog(). Core's dialog behavior calls + * .dialog('option', ...) on the closest .ui-dialog-content of every AJAX + * inserted context (e.g. a managed file upload inside the popup), which + * throws "cannot call methods on dialog prior to initialization". Skip the + * core behavior for contexts inside the fake popup dialog. + */ + if (Drupal.behaviors.dialog && !Drupal.behaviors.dialog.iefPopupWrapped) { + const originalDialogAttach = Drupal.behaviors.dialog.attach; + Drupal.behaviors.dialog.attach = function (context, settings) { + if (context !== document && + typeof context.closest === 'function') { + const dialog = context.closest('.ui-dialog-content'); + if (dialog && + dialog.closest('.ief-popup-wrapper') && + !$(dialog).data('uiDialog')) { + return; + } + } + return originalDialogAttach.apply(this, arguments); + }; + Drupal.behaviors.dialog.iefPopupWrapped = true; + } + Drupal.behaviors.ief_popup = { attach: function (context, settings) {