From 94370312b71be272099f3ed45ee5cae263e46c84 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 15 May 2026 20:28:55 +0000 Subject: [PATCH] Fix: Prevent collapse of Complex Fields when adding new entries When clicking 'Add Entry' in the Datenbereitstellung (Data Preparation) tab, the entire Complex Field was unexpectedly collapsing. This was due to event bubbling causing the collapse toggle to be triggered. Added odw-complex-fix.js which uses stopPropagation() to prevent the 'Add Entry' button click from bubbling up to parent elements that might trigger collapse handlers. https://claude.ai/code/session_01JB1xUQM892bVZ4Yv3MZjvq --- assets/js/odw-complex-fix.js | 32 ++++++++++++++++++++++++++++++++ includes/class-admin.php | 8 ++++++++ 2 files changed, 40 insertions(+) create mode 100644 assets/js/odw-complex-fix.js 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 ) {