To reproduce
- Create a menu link to an anchor on a page
- Navigate to the page.
- In a mobile view, open the menu and click the link to the page
- I expect the menu to close and the anchor to be scrolled to. However nothing happens.
This can also be reproduced on Tugboat at https://tugboat-aqrmztryfqsezpvnghut1cszck2wwasr.tugboat.qa/node/7#comments. The menu link is "Nested Comments" and is under the "Features" top level menu item
Note this came from this slack conversation: https://drupal.slack.com/archives/CJT807H7T/p1625154993136300
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | Screen Recording 2021-08-12 at 10.21.53 AM.mov | 3.57 MB | gauravvvv |
| #10 | 3221871-10-test-only-FAIL.patch | 1.3 KB | mherchel |
| #10 | interdiff-9-10.txt | 611 bytes | mherchel |
| #10 | 3221871-10.patch | 2.68 KB | mherchel |
| #9 | 3221871-9-test-only-FAIL.patch | 1.3 KB | mherchel |
Comments
Comment #2
mherchelPatch attached.
Comment #3
nod_This work as expected, pretty elegant too.
Comment #4
w01f commentedCatching up on this from the slack chat. The patch applied cleanly, but something is caching the site I haven't found yet so I will retest tomorrow and follow up. I don't see anything in the patch about removing js-fixed, but I'm assuming somehow it does that as well?
Thanks so much for looking into this and will follow up this weekend!
Comment #5
w01f commentedAlso tested and works great!
Comment #6
mherchelComment #7
lauriii"mobile" should be on the previous line. This can be fixed on commit. Other than that, all looks good!
Comment #8
lauriiiComing back at this now, I'm wondering if we could add tests for this?
Comment #9
mherchelTests added. The tests actually caught something, too. If the link didn't have a leading forward slash
/, it would not work properly. So, the JavaScript is updated too.Comment #10
mherchelGah. Forgot a trailing semicolon in the test. New patches attached.
Comment #11
gauravvvv commentedPatch #10, fixes the issue. Now on clicking to the menu link having id on same works in mobile too. Menu is closing and page scroll down the element having same id as in menu link.
RTBC+1
Attached after patch screen recording for reference.
Comment #14
lauriiiCommitted 4f8c468 and pushed to 9.3.x. Cherry-picked to 9.2.x because Olivero is experimental. Thanks!