WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.57k stars 4.22k forks source link

Clicking Navigation links on the current page should close the mobile overlay. #58515

Open scruffian opened 10 months ago

scruffian commented 10 months ago

What problem does this address?

The navigation block supports anchor/on-page links inside the overlay. When a user clicks these they navigate to the correct part of the page but the overlay doesn't close so it's not clear that has happened.

What is your proposed solution?

We should close the overlay when links inside it are clicked.

getdave commented 1 week ago

@annezazu This would be quite important in order to build a single page website. Without the whole concept breaks down on mobile.

I propose this is actually quite an important issue.

My recommendation to fix would be to use the Interactivity API and apply special handling to any "internal" links (those containing only #someanchor as the url value).

Some of this is here

https://github.com/WordPress/gutenberg/blob/b7d989e0dafb23866f65295a851e6b8734c3b693/packages/block-library/src/navigation/index.php#L498

But we might want to add to the core/navigation-link block itself:

https://github.com/WordPress/gutenberg/blob/b7d989e0dafb23866f65295a851e6b8734c3b693/packages/block-library/src/navigation-link/index.php#L1