[wp-trac] [WordPress Trac] #57308: Nav menu on Mobile remains open after clicking on an anchor link
WordPress Trac
noreply at wordpress.org
Sun Dec 11 01:48:19 UTC 2022
#57308: Nav menu on Mobile remains open after clicking on an anchor link
-------------------------------------------------+-------------------------
Reporter: nickpagz | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Menus | Version:
Severity: normal | Resolution:
Keywords: needs-testing has-testing-info | Focuses:
reporter-feedback |
-------------------------------------------------+-------------------------
Comment (by nickpagz):
@costdev I've been able to narrow down the issue to the format of the link
used.
If you simply use `#news` as your link, then all works fine. However, the
link doesn't work if you're on a different page. Clicking it reloads the
same page as the link is relative to the current page. So this really only
works for single-page sites.
Using `/#news` will get you back to the homepage and the correct anchor.
However, clicking on the link from the homepage causes the menu overlay to
remain open.
Using an absolute url will work if you omit `https://` (since it defaults
to http) or use `http://`. Http works presumably because of the redirect
to https, which causes a page reload which closes the menu overlay.
I'm not sure of the implications of having the links set to http from an
SEO perspective, but a redirect and page reload seems less than ideal if
you're already on the page. It seems like the best approach at the moment
is an absolute url with an http protocol or omitting the protocol
altogether is the only solution that works, as far as I can tell.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57308#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list