From ece2467946cede1538a6d5ceec5c683e39632341 Mon Sep 17 00:00:00 2001 From: David Arenas Date: Sat, 16 Dec 2023 18:36:30 +0100 Subject: [PATCH] Do not render state when `data` is not present --- .../plugins/interactive-blocks/router-navigate/render.php | 6 +++++- test/e2e/specs/interactivity/router-navigate.spec.ts | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/e2e-tests/plugins/interactive-blocks/router-navigate/render.php b/packages/e2e-tests/plugins/interactive-blocks/router-navigate/render.php index 66a1a356e4a79..f6102a96bf8c8 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/router-navigate/render.php +++ b/packages/e2e-tests/plugins/interactive-blocks/router-navigate/render.php @@ -15,6 +15,10 @@ array( 'clientNavigationDisabled' => true ) ); } + +if ( isset( $attributes['data'] ) ) { + $initial_state = array( 'router' => array( 'data' => $attributes['data'] ) ); +} ?>
diff --git a/test/e2e/specs/interactivity/router-navigate.spec.ts b/test/e2e/specs/interactivity/router-navigate.spec.ts index a05b6fc3fba70..722bce1593cd5 100644 --- a/test/e2e/specs/interactivity/router-navigate.spec.ts +++ b/test/e2e/specs/interactivity/router-navigate.spec.ts @@ -14,7 +14,7 @@ test.describe( 'Router navigate', () => { alias: 'router navigate - link 1', attributes: { title: 'Link 1', - state: { prop1: 'link 1', prop3: 'link 1' }, + data: { prop1: 'link 1', prop3: 'link 1' }, }, } ); await utils.addPostWithBlock( 'test/router-navigate', { @@ -22,7 +22,7 @@ test.describe( 'Router navigate', () => { attributes: { title: 'Main', links: [ link1, link2 ], - state: { prop1: 'main', prop2: 'main' }, + data: { prop1: 'main', prop2: 'main' }, }, } ); await utils.addPostWithBlock( 'test/router-navigate', {