Skip to content

Commit 226df91

Browse files
authored
Lightbox UI appearing with interactivity experiment disabled (#51025)
* Fix lightbox ui appearing with interactivity experiment disabled * Update e2e tests to enable the experiment
1 parent 9a686da commit 226df91

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

lib/experimental/editor-settings.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ function gutenberg_enable_experiments() {
8989
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-pattern-enhancements', $gutenberg_experiments ) ) {
9090
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnablePatternEnhancements = true', 'before' );
9191
}
92+
if ( $gutenberg_experiments && array_key_exists( 'gutenberg-interactivity-api-core-blocks', $gutenberg_experiments ) ) {
93+
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalInteractivityAPI = true', 'before' );
94+
}
9295

9396
}
9497

packages/block-editor/src/hooks/behaviors.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export const withBehaviors = createHigherOrderComponent( ( BlockEdit ) => {
3838
const settings =
3939
select( blockEditorStore ).getSettings()?.__experimentalFeatures
4040
?.blocks?.[ props.name ]?.behaviors;
41-
4241
if (
4342
! settings ||
4443
// If every behavior is disabled, do not show the behaviors inspector control.
@@ -102,8 +101,10 @@ export const withBehaviors = createHigherOrderComponent( ( BlockEdit ) => {
102101
};
103102
}, 'withBehaviors' );
104103

105-
addFilter(
106-
'editor.BlockEdit',
107-
'core/behaviors/with-inspector-control',
108-
withBehaviors
109-
);
104+
if ( window?.__experimentalInteractivityAPI ) {
105+
addFilter(
106+
'editor.BlockEdit',
107+
'core/behaviors/with-inspector-control',
108+
withBehaviors
109+
);
110+
}

test/e2e/specs/editor/various/behaviors.spec.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,32 @@ test.describe( 'Testing behaviors functionality', () => {
2121
await requestUtils.activateTheme( 'twentytwentyone' );
2222
await requestUtils.deleteAllPosts();
2323
} );
24+
test.beforeEach( async ( { admin, page, requestUtils } ) => {
25+
await requestUtils.deleteAllMedia();
26+
await admin.visitAdminPage(
27+
'/admin.php',
28+
'page=gutenberg-experiments'
29+
);
30+
31+
await page
32+
.locator( `#gutenberg-interactivity-api-core-blocks` )
33+
.setChecked( true );
34+
await page.locator( `input[name="submit"]` ).click();
35+
await page.waitForLoadState();
36+
} );
2437

25-
test.afterEach( async ( { requestUtils } ) => {
38+
test.afterEach( async ( { admin, page, requestUtils } ) => {
2639
await requestUtils.deleteAllMedia();
40+
await admin.visitAdminPage(
41+
'/admin.php',
42+
'page=gutenberg-experiments'
43+
);
44+
45+
await page
46+
.locator( `#gutenberg-interactivity-api-core-blocks` )
47+
.setChecked( false );
48+
await page.locator( `input[name="submit"]` ).click();
49+
await page.waitForLoadState();
2750
} );
2851

2952
test( '`No Behaviors` should be the default as defined in the core theme.json', async ( {

0 commit comments

Comments
 (0)