From a5b02b969c5b40577ca8926e8131e2d4bc0e517d Mon Sep 17 00:00:00 2001 From: Grant Kinney Date: Sun, 28 Jul 2024 20:20:03 -0500 Subject: [PATCH] Attempts to add interactivity API to show tab on click --- packages/block-library/src/tab/save.js | 1 + packages/block-library/src/tabs/block.json | 3 ++- packages/block-library/src/tabs/save.js | 10 ++++++++-- packages/block-library/src/tabs/view.js | 13 +++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 packages/block-library/src/tabs/view.js diff --git a/packages/block-library/src/tab/save.js b/packages/block-library/src/tab/save.js index e0d50b1cbac879..dca2d2856dbed3 100644 --- a/packages/block-library/src/tab/save.js +++ b/packages/block-library/src/tab/save.js @@ -18,6 +18,7 @@ export default function save( { attributes } ) {
diff --git a/packages/block-library/src/tabs/block.json b/packages/block-library/src/tabs/block.json index 89b715f064d9ba..49598ad5521195 100644 --- a/packages/block-library/src/tabs/block.json +++ b/packages/block-library/src/tabs/block.json @@ -41,5 +41,6 @@ } }, "editorStyle": "wp-block-tabs-editor", - "style": "wp-block-tabs" + "style": "wp-block-tabs", + "viewScriptModule": "file:./view.min.js" } diff --git a/packages/block-library/src/tabs/save.js b/packages/block-library/src/tabs/save.js index e858f9c43f4da0..dc7637d9b002cd 100644 --- a/packages/block-library/src/tabs/save.js +++ b/packages/block-library/src/tabs/save.js @@ -20,7 +20,11 @@ export default function save( { attributes } ) { } ); return ( -
+
    { innerTabs.map( ( tab, index ) => { const isActive = index === 0; @@ -34,7 +38,9 @@ export default function save( { attributes } ) { > { + const context = getContext(); + context.activeTab = index; + }, + }, +} );