diff --git a/assets/js/odw-complex-fix.js b/assets/js/odw-complex-fix.js new file mode 100644 index 0000000..8ac8537 --- /dev/null +++ b/assets/js/odw-complex-fix.js @@ -0,0 +1,32 @@ +/** + * Open Data Wizard — Complex Field Collapse Fix + * + * Verhindert, dass beim Klick auf "Add Entry" in Complex Fields + * das Collapse-Toggle versehentlich mit ausgelöst wird (Event-Bubbling-Problem). + */ +(function () { + 'use strict'; + + function preventCollapseOnAddEntry() { + // Beobachte alle Carbon Fields Complex Field action buttons. + // "Add Entry" Button sitzt in .cf-complex__actions + document.addEventListener( 'click', function ( e ) { + // Suche nach dem direkten Button-Element (Add Entry Button) + var button = e.target.closest( '.cf-complex__actions button' ); + if ( ! button ) { + return; + } + + // Stoppe Event-Bubbling, damit der Click nicht zu + // einem Collapse-Toggle bubbelt + e.stopPropagation(); + }, true ); // Use capture phase, damit es vor anderen Listenern läuft + } + + // Starte sobald DOM ready ist + if ( document.readyState === 'loading' ) { + document.addEventListener( 'DOMContentLoaded', preventCollapseOnAddEntry ); + } else { + preventCollapseOnAddEntry(); + } +})(); diff --git a/includes/class-admin.php b/includes/class-admin.php index ae6dfac..07a1a95 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -282,6 +282,14 @@ public static function enqueue_assets( string $hook ): void { true ); + wp_enqueue_script( + 'odw-complex-fix', + ODW_PLUGIN_URL . 'assets/js/odw-complex-fix.js', + array(), + ODW_VERSION, + true + ); + // Build license auto-suggest options from config/licenses.txt. $license_file_options = array(); foreach ( ODW_Fields::load_license_list() as $uri => $label ) {