-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix for navigation anchor links to close modal #45829
Fix for navigation anchor links to close modal #45829
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @coreyworrell! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, it fixes the issue for me.
Congratulations on your first merged pull request, @coreyworrell! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts: https://profiles.wordpress.org/me/profile/edit/ And if you don't have a WordPress.org account, you can create one on this page: https://login.wordpress.org/register Kudos! |
@coreyworrell Thanks so much for taking the time here and congrats on your first Gutenberg PR 🥳 |
What?
Allows the navigation block modal to close if you click on an item that is linked to an anchor on the current page.
Why?
Currently links like
/#anchor
or/some-page/#anchor
do not close the modal. It only closes if thehref
exactly starts with#
. So if you are on/some-page/
and you click the/some-page/#anchor
link, it will scroll down to the anchor, but the modal will remain open.How?
Modified the link click handler to test if the
href
contains a hash and it matches the current page (protocol, host, pathname, and search).Testing Instructions
/page/#anchor
/page/
), open modal menu, click link. Modal should remain open as browser navigation happens./page/
, open modal menu, click link. Modal should close and you remain on page (and browser scrolls to the anchor if you've added an element with the anchor ID).Screenshots or screencast