Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut
) ) {
// Add directives to the parent `<li>`.
$tags->set_attribute( 'data-wp-interactive', 'core/navigation' );
$tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": { "click": false, "hover": false, "focus": false }, "type": "submenu" }' );
$tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": { "click": false, "hover": false, "focus": false }, "type": "submenu", "modal": null }' );
$tags->set_attribute( 'data-wp-watch', 'callbacks.initMenu' );
$tags->set_attribute( 'data-wp-on--focusout', 'actions.handleMenuFocusout' );
$tags->set_attribute( 'data-wp-on--keydown', 'actions.handleMenuKeydown' );
Expand Down
6 changes: 6 additions & 0 deletions packages/interactivity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

### Bug Fixes

- Fix property modification from inherited context two or more levels above ([#66872](https://github.com/WordPress/gutenberg/pull/66872)).

## 6.11.0 (2024-10-30)

### Bug Fixes

- Fix reactivity of undefined objects and arrays added with `deepMerge()` ([#66183](https://github.com/WordPress/gutenberg/pull/66183)).

## 6.10.0 (2024-10-16)
Expand Down
3 changes: 3 additions & 0 deletions packages/interactivity/src/proxies/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const contextHandlers: ProxyHandler< object > = {
getOwnPropertyDescriptor: ( target, key ) =>
descriptor( target, key ) ||
descriptor( contextObjectToFallback.get( target ), key ),
has: ( target, key ) =>
Reflect.has( target, key ) ||
Reflect.has( contextObjectToFallback.get( target ), key ),
};

/**
Expand Down
18 changes: 18 additions & 0 deletions packages/interactivity/src/proxies/test/context-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,24 @@ describe( 'Interactivity API', () => {
expect( context.a ).toBe( 2 );
expect( state.a ).toBe( 2 );
} );

it( "should modify props inherited from fallback's ancestors", () => {
const ancestor: any = proxifyContext(
{ ancestorProp: 'ancestor' },
{}
);
const fallback: any = proxifyContext(
{ fallbackProp: 'fallback' },
ancestor
);
const context: any = proxifyContext( {}, fallback );

context.ancestorProp = 'modified';

expect( context.ancestorProp ).toBe( 'modified' );
expect( fallback.ancestorProp ).toBe( 'modified' );
expect( ancestor.ancestorProp ).toBe( 'modified' );
} );
} );

describe( 'computations', () => {
Expand Down