Support » Theme: Twenty Seventeen » Twenty Seventeen mobile menu – close on click – Safari

  • Resolved Morphim

    (@morphim)


    Hello.
    With reference to this thread: https://wordpress.org/support/topic/create-sticky-collapsable-menu-on-mobile-phone/

    I was looking for a solution to the mobile Twenty Seventeen menu closing when a link is clicked.
    The code mentioned in the above link works but, I have pop up windows (like lightbox) on my site for video and images (two different plugins that use PrettyPhoto and FancyBox)
    The script mentioned here causes a problem with the pop-ups but only on Safari (it’s always Safari!!)

    Basically, with this code, when clicking the video or image lighbox popups, they don’t open and the Safari browser jumps to the top of the page. If you then scroll back down to the video / image, it will open . But, if you close the lighbox and try again, it scrolls to the top again.

    If I remove this ‘close mobile menu on click’ code from my functions.php, everything works as it should, obviously except the close menu on click function.

    Any ideas why this might be? (I Know this is quite an old initial topic)

    Thanks in advance

Viewing 12 replies - 1 through 12 (of 12 total)
  • Moderator Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Hi again, would you be able to provide a link to your site?

    I can but I’ve deactivated it as it’s now an active site. I have a test site. I’ll see if i can set it up on that. Back soon …

    Hi there, This site should function the same. I’ve not checked in Safari yet though to see if the problem is still present here.

    Moderator Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Thanks, what do I have to click on to replicate this:

    when clicking the video or image lighbox popups, they don’t open and the Safari browser jumps to the top of the page.

    Thanks for your time on this. I have tested it now and it does the same

    You need to be on Safari and I’ve only tested on a Mac. (it doesn’t seem to do this with FF, Edge or Chrome on either Mac or PC)
    If you scroll down to the 2 x 2 grid of video thumbnails, under the ‘Work’ heading, when clicking any of these, it should open a popup window with the video.

    However, what it actually does, when clicked, is scroll to the top of the page. If you then scroll back down to the videos, whichever you click opens correctly.
    However, if you then close and re-click or try to open a different one, it scrolls to the top again.

    Hope fully that makes sense.
    Please let me know how you get on.
    Thanks again

    Moderator Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Oh I think I unnderstand, your issue is not on mobile but desktop?

    Moderator Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Can you triple check that my code is causing this issue?

    My ‘main.js’ code only does the following:

    1. Finds all internal links in the main navigation menu (by checking if the link has a hash character)
    2. For each link, it checks that the link points to something on the same page and not on another page
    3. For only links that point to things on the same page, it finds where the links are going – the destinations
    4. Then it enhances accessibility to make sure the destinations can be accessed for keyboard users
    5. Then tracks when people click on one of the links (in the menu) (that point to something on the same page)
    6. And on click of one of those links, it checks whether the mobile menu button is visible
    7. If the mobile menu button is visible, then the script hides the mobile menu

    The only part I can see that could affect your lightbox is step 4. To rule that out and to remove the accessibility enhancement, try this PasteBin code instead: https://pastebin.com/BVfYGcEJ

    • This reply was modified 1 year, 6 months ago by  Andrew Nevins.
    • This reply was modified 1 year, 6 months ago by  Andrew Nevins.
    Moderator Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    So, the only action points are steps 4 and 7 – the rest of the steps are just checks.

    Hi Andrew. Thank you so much for taking a look at this for me.

    Your updated main.js code seems to have done the trick. Brilliant. You’re a genius; for the original code and for giving your time to help me with the new code.

    I’m very grateful and appreciate you giving your time freely for all of this.

    I’m no coder so have little idea what is going on or what affects what.

    My hearty thanks again : )

    Oh, by the way, yes, it was only desktop and only safari. Very odd.

    Sorry. Forgot to click ‘resolved

    Moderator Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Too kind! If you have any more issues just open a new thread 🙂

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Twenty Seventeen mobile menu – close on click – Safari’ is closed to new replies.