From fed4671dca77826eb43642748b4fde520cde56d3 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Mon, 25 Mar 2024 11:46:05 +0200 Subject: [PATCH] Don't close the overlay when hovering out of pre prendered submenus (#60130) Unlinked contributors: ariel-maidana. Co-authored-by: draganescu Co-authored-by: scruffian Co-authored-by: SantosGuillamot Co-authored-by: annezazu Co-authored-by: fabiankaegy Co-authored-by: huzaifaalmesbah Co-authored-by: kjnanda Co-authored-by: youknowriad Co-authored-by: colorful-tones Co-authored-by: liviopv --- packages/block-library/src/navigation/view.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation/view.js b/packages/block-library/src/navigation/view.js index aa12ea4473b32a..4efc18e20250b4 100644 --- a/packages/block-library/src/navigation/view.js +++ b/packages/block-library/src/navigation/view.js @@ -66,7 +66,14 @@ const { state, actions } = store( actions.openMenu( 'hover' ); }, closeMenuOnHover() { - actions.closeMenu( 'hover' ); + const { type, overlayOpenedBy } = getContext(); + if ( + type === 'submenu' && + // Only open on hover if the overlay is closed. + Object.values( overlayOpenedBy || {} ).filter( Boolean ) + .length === 0 + ) + actions.closeMenu( 'hover' ); }, openMenuOnClick() { const ctx = getContext();