Description
The mobile menu modal doesn't stay closed after clicking the close icon when the hamburger menu icon is directly underneath the modal's close icon.
AFAICT, the reason is that the modal closes on touchstart which exposes the hamburger menu icon underneath and the touchend when releasing the mouse button triggers a click on the hamburger menu icon which then opens the menu again.
A local fix of adding preventDefault to the touchstart event before calling closeModal in the onClick method fixes the issue.
if( e.type === 'touchstart' && e.target.hasAttribute( this.config.closeTrigger ) ) {
e.preventDefault()
}
Alternatively, change triggering the onClick method from touchstart event to a click event instead.
Hope that helps!
Step-by-step reproduction instructions
- Activate a FSE theme
- Open the Site Editor and add the navigation block to the index template or header template part
- Make sure the
Enable responsive menu option is selected and a menu with menu items is selected
- Save the template or template part
- Switch to the frontend of the site
- Activate Device emulator in the developer tools and pick a mobile device
- Make sure a device is picked that triggers the display of the hamburger menu
- Open the menu modal by clicking the hamburger menu icon and make sure the close icon is directly over the hamburger menu icon
- Click the close icon
- Observe that the menu modal will be re-opened immediately after releasing the mouse button
- Open the menu again
- Now press the menu button when hovering the close icon
- Keep the mouse button pressed
- The menu modal should be closed and expose the hamburger menu icon
- Move the mouse away from the hamburger menu icon and release the mouse button
- Observe that the menu does not re-open
Screenshots, screen recording, code snippet

The first two clicks on the close icon show the issue as described above in steps 9-10. The two clicks after show steps 12-16.
Environment info
WordPress 5.8.1
Gutenberg 11.7
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Description
The mobile menu modal doesn't stay closed after clicking the close icon when the hamburger menu icon is directly underneath the modal's close icon.
AFAICT, the reason is that the modal closes on
touchstartwhich exposes the hamburger menu icon underneath and thetouchendwhen releasing the mouse button triggers a click on the hamburger menu icon which then opens the menu again.A local fix of adding preventDefault to the
touchstartevent before callingcloseModalin theonClickmethod fixes the issue.Alternatively, change triggering the onClick method from
touchstartevent to aclickevent instead.Hope that helps!
Step-by-step reproduction instructions
Enable responsive menuoption is selected and a menu with menu items is selectedScreenshots, screen recording, code snippet
The first two clicks on the close icon show the issue as described above in steps 9-10. The two clicks after show steps 12-16.
Environment info
WordPress 5.8.1
Gutenberg 11.7
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes