[wp-trac] [WordPress Trac] #49025: Twenty Twenty: Modal menu link with hash should scroll to that section on the page.
WordPress Trac
noreply at wordpress.org
Thu Feb 27 14:05:54 UTC 2020
#49025: Twenty Twenty: Modal menu link with hash should scroll to that section on
the page.
---------------------------+------------------------------
Reporter: acosmin | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Bundled Theme | Version: 5.3.1
Severity: normal | Resolution:
Keywords: | Focuses: ui, javascript
---------------------------+------------------------------
Comment (by bdcstr):
Noticed the same issue. This is my **temporary-and-not-perfect** solution
(so don't judge me!) while waiting for the official patch.
1. Go to themes/twentytwenty/assets/js/index.js
2. Look for the `outsideUntoggle: function () {` (at line 135 for me)
3. Change with the following code:
{{{
outsideUntoggle: function () {
document.addEventListener('click', function (event) {
var target = event.target;
var modal = document.querySelector('.cover-modal.active');
// if target on click is <a> with # within the href attribute
if (event.target.tagName.toLowerCase() === 'a' &&
event.target.hash.includes('#')) {
// untoggle the modal
this.untoggleModal(modal);
// wait 550 and scroll to the anchor
setTimeout(function () {
var anchor =
document.getElementById(event.target.hash.slice(1)); //
anchor.scrollIntoView();
}, 550);
}
if (target === modal) {
this.untoggleModal(target);
}
}.bind(this));
},
}}}
4. Hope it helps ;)
Cheers!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49025#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list