Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation mobile overlay closes unintentionally after clicking on submenu button #60371

Closed
fabiankaegy opened this issue Apr 2, 2024 · 5 comments · Fixed by #60406
Closed
Labels
[Block] Navigation Affects the Navigation Block [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release

Comments

@fabiankaegy
Copy link
Member

When the navigation block is set to open submenus via the click event instead of hover, the mobile submenu collapses unintentionally after the user clicks on the submenu button once. See the attached video.

CleanShot.2024-04-02.at.14.59.49.mp4
@fabiankaegy fabiankaegy added [Type] Bug An existing feature does not function as intended [Block] Navigation Affects the Navigation Block labels Apr 2, 2024
@fabiankaegy
Copy link
Member Author

CC: @WordPress/interactivity-api

@annezazu
Copy link
Contributor

annezazu commented Apr 2, 2024

@fabiankaegy is this happening in 6.5? If so, we should at this as a point release bug potentially.

@fabiankaegy
Copy link
Member Author

@annezazu it is but I have not been able to test whether it isn't happening in 6.4.3.

Will do that tomorrow.

But yeah I do think this would be a nice point update

@fabiankaegy
Copy link
Member Author

Okay I was able to test it on 6.4.3 now and the issue does not happen there. So it is 6.5 specify. Because of that I do think that we should add this to a patch release

@fabiankaegy fabiankaegy added [Priority] High Used to indicate top priority items that need quick attention [Type] Regression Related to a regression in the latest release labels Apr 3, 2024
@fabiankaegy
Copy link
Member Author

I've been able to use the debugger to figure out that the issue is happening here:

handleMenuFocusout( event ) {
const { modal } = getContext();
// If focus is outside modal, and in the document, close menu
// event.target === The element losing focus
// event.relatedTarget === The element receiving focus (if any)
// When focusout is outsite the document,
// `window.document.activeElement` doesn't change.
// The event.relatedTarget is null when something outside the navigation menu is clicked. This is only necessary for Safari.
if (
event.relatedTarget === null ||
( ! modal?.contains( event.relatedTarget ) &&
event.target !== window.document.activeElement )
) {
actions.closeMenu( 'click' );
actions.closeMenu( 'focus' );
}
},

When you click away from the button element the focus gets lost for a moment which gets used as a trigger to close the navigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants