From 80a472ca1b08f8c3626ccd315a4931be757852a8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 17 May 2026 17:52:58 +0000 Subject: [PATCH 1/2] Fix: Detect Tab 3 activation to auto-show distribution fields Previous approach used a wrong selector and 500ms timeout which ran before Tab 3 was ever activated (Carbon Fields renders tabs lazily). New approach uses a MutationObserver that watches for the .cf-complex__placeholder to appear in the DOM (happens when Tab 3 is first clicked), then clicks the 'Add Entry' inserter button automatically. Runs once per page load. https://claude.ai/code/session_01JB1xUQM892bVZ4Yv3MZjvq --- assets/js/odw-admin-fields.js | 47 +++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/assets/js/odw-admin-fields.js b/assets/js/odw-admin-fields.js index 8809c36..6f89664 100644 --- a/assets/js/odw-admin-fields.js +++ b/assets/js/odw-admin-fields.js @@ -220,27 +220,42 @@ } // ------------------------------------------------------------------------- - // Auto-show distribution fields by clicking "Add Entry" on load + // Auto-show distribution fields when Tab 3 is activated // ------------------------------------------------------------------------- function autoShowDistributionFields() { - // Find the distributions complex field container - var distributionsContainer = document.querySelector( '[data-carbon-field="odw_distributions"]' ); - if ( ! distributionsContainer ) { - return; - } + // Only run once per page load + var ran = false; - // Check if there are any existing entries (groups) - var existingGroups = distributionsContainer.querySelectorAll( '.cf-complex__group' ); - if ( existingGroups.length > 0 ) { - // Entries already exist, no need to auto-add - return; - } + function tryClickAddEntry() { + if ( ran ) { + return; + } + + // The placeholder is only visible when there are no entries yet + var placeholder = document.querySelector( '.cf-complex__placeholder' ); + if ( ! placeholder ) { + return; + } - // No entries exist, click "Add Entry" to show empty form - var addButton = distributionsContainer.querySelector( '.cf-complex__actions button' ); - if ( addButton ) { - addButton.click(); + // Find the "Add Entry" inserter button next to or after the placeholder + var inserterButton = document.querySelector( '.cf-complex__inserter-button' ); + if ( ! inserterButton ) { + return; + } + + ran = true; + inserterButton.click(); } + + // Watch for Carbon Fields rendering the placeholder (lazy tab render) + var observer = new MutationObserver( function () { + tryClickAddEntry(); + } ); + + observer.observe( document.body, { childList: true, subtree: true } ); + + // Also try immediately in case tab is already active + tryClickAddEntry(); } // ------------------------------------------------------------------------- From 0e789d191f20e110c6a6714df93c5d455365c125 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 17 May 2026 17:53:10 +0000 Subject: [PATCH 2/2] Version 2.1.2: Fix Tab 3 distribution fields auto-show https://claude.ai/code/session_01JB1xUQM892bVZ4Yv3MZjvq --- open-data-wizard.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/open-data-wizard.php b/open-data-wizard.php index a54f82c..b52dad7 100644 --- a/open-data-wizard.php +++ b/open-data-wizard.php @@ -3,7 +3,7 @@ * Plugin Name: Open Data Wizard * Plugin URI: https://github.com/daimpad/OpenDataWizard * Description: DCAT-AP 3.0 konforme Open Data Metadatenverwaltung für WordPress. Bereitstellung als maschinenlesbarer JSON-LD-Endpoint für offene Daten. - * Version: 2.1.1 + * Version: 2.1.2 * Requires at least: 6.4 * Requires PHP: 8.1 * Author: nozilla @@ -25,7 +25,7 @@ exit; } -define( 'ODW_VERSION', '2.1.1' ); +define( 'ODW_VERSION', '2.1.2' ); define( 'ODW_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'ODW_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'ODW_PLUGIN_FILE', __FILE__ );