Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1438466

    Good day,
    When using the Health Demo as the basis for my homepage I have the following problem and cannot solve it.
    If I select a submenu item in the Service menu (e.g. Nutrition) and then navigate back using the Safari browser’s back button, the menu is not displayed correctly. (the menu is opened and the menu sub-item of my previous selection is displayed).
    This error appears on the iPAD in the Safari browser during the demo https://kriesi.at/themes/enfold-health-coach/
    but also on my own homepage. I cleared the cache several times, but that didn’t solve the problem.
    I know I could use the burger menu for iPAD, but I want to use the normal menu for landscape mode.

    Thank you very much for your help and
    With kind regards
    Bruno

    #1438504

    Hey Bruno,
    Thanks for the screenshots, I tested this on my demo site with Safari on Mac and Firefox on Windows and the sub-menu and the burger menu were open when the browser back button was used, this is due to the browser serving a browser cached version of the page. The following javascript solved this in my tests, I recommend using the WP Code plugin then add a new snippet, in the top right corner use the javascript snippet as the code type:
    Enfold_Support_5190.jpeg
    and add this code:

    window.addEventListener('pageshow', (event) => {
        if (window.matchMedia('(min-width: 990px)').matches) {
            document.querySelectorAll('.sub-menu').forEach((subMenu) => {
                subMenu.style.opacity = '0';
                subMenu.style.visibility = 'hidden';
            });
        } else {
            const overlay = document.querySelector('.av-burger-overlay');
            if (overlay) {
                overlay.style.display = 'none';
                overlay.style.opacity = '0';
            }
            const hamburger = document.querySelector('.av-hamburger');
            if (hamburger) {
                hamburger.classList.remove('is-active');
            }
            document.documentElement.classList.remove('av-burger-overlay-active', 'av-burger-overlay-active-delayed');
        }
    });
    
    

    Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.
    After applying the css, please clear your browser cache and check.

    Best regards,
    Mike

    #1438509

    Hi Mike,
    Many thanks for the quick response. I added the snippset and can report partial success.

    1. It works with normal menus, but I would like to create a mega menu under the menu item “Unsere Birmas”. Unfortunately, this doesn’t work; the mega menu is not displayed on the desktop and on iPAD in landscape mode. It is just a white rectangle without submenu items visible. As mentioned above, if I use the normal menu instead of the mega menu, it works.”

    2. For sidebar pages with the navigation menu widget, the page navigation menu is only displayed correctly on the mobile phone and on the iPAD in portrait mode. In landscape mode, the submenu items are missing on the desktop and iPAD.
    I added in the WP Code plugin under Intelligent Conditional Logiccode as an example for the page https://hallo.dospuntas.ch/wurf-1-2024/
    to hide the snippet.
    On the page https://hallo.dospuntas.ch/wurf-2-2024/ and the others you can see what it looks like without this logic entry and the page navigation menu is incomplete. Do I now need to add an entry in the logic for all pages with page navigation or is there an easier solution to get this to display correctly on the iPAD in landscape mode and on the desktop?

    3. Burger menu on mobile phone and iPad in portrait format:
    When you press the back button and then open the menu, the previously selected submenu items are open/visible. If you repeat this with other menu items, you’ll end up with all submenu items expanded rather than closed as they should be.

    I would be grateful if you could help me resolve the remaining issues.

    Many thanks and kind regards
    Bruno

    #1438543

    Hi,
    Please try this snippet instead:

    window.addEventListener('pageshow', (event) => {
        if (window.matchMedia('(min-width: 990px)').matches) {
            document.querySelectorAll('#avia-menu .sub-menu').forEach((subMenu) => {
                subMenu.style.opacity = '0';
                subMenu.style.visibility = 'hidden';
                subMenu.style.display = 'none';
            });
        } else {
            const overlay = document.querySelector('.av-burger-overlay');
            if (overlay) {
                overlay.style.display = 'none';
                overlay.style.opacity = '0';
            }
    
            const hamburger = document.querySelector('.av-hamburger');
            if (hamburger) {
                hamburger.classList.remove('is-active');
            }
            document.querySelectorAll('.av-active-burger-items .sub-menu').forEach((subMenu) => {
                subMenu.style.display = 'none';
            });
    		document.querySelectorAll('.av-active-burger-items .av-width-submenu').forEach((withsubMenu) => {
                withsubMenu.classList.remove('av-show-submenu');
            });
    
            document.documentElement.classList.remove('av-burger-overlay-active', 'av-burger-overlay-active-delayed');
        }
    });

    and don’t use Smart Conditional Logic.
    Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.

    Best regards,
    Mike

    #1438573

    Hello Mike, thank you very much for your answer, unfortunately not everything works as expected, here are the results:

    Point 1
    Desktop: Menu sub-items from the normal menu and mega menu are not visible and therefore no navigation is possible.
    iPAD Landscape: Mega menu not visible.
    Display of the normal menu incorrect and unreliable: When accessing the website, the submenu items are not visible.
    Only after selecting various menu items several times and updating the website are the submenu items sometimes displayed
    and then not displayed the next time.

    iPAD Portrait (burger menu): Display and navigation work perfectly
    Handy Portrait (burger menu): Display and navigation work perfectly
    Handy Landscape (burger menu): Display and navigation works perfectly

    Point 2
    Desktop: The page navigation menu works on these pages, but no access to the pages via the menu as already mentioned in point 1
    iPAD Landscape/Portrait and Handy Landscape/Portrait: works perfectly

    Point 3 works perfectly

    I would be grateful if you could help me to solve the remaining problems under point 1.
    Many thanks and best regards
    Bruno

    #1438676

    Hi,
    Please include a admin login in the Private Content area so we can examine.

    Best regards,
    Mike

    #1438678

    Hello Mike, here is the administrator login.

    Best regards
    Bruno

    #1438760

    Hi,
    Thank for the login, I disable the previous solution and added this javascript solution:

    window.addEventListener('pageshow', (event) => {
        if (event.persisted) {
    			if (window.matchMedia('(min-width: 990px)').matches) {
            const menu = document.getElementById('avia-menu');
            const visibleSubMenus = menu.querySelectorAll('ul.sub-menu[style*="opacity: 1"]');
            if (visibleSubMenus.length > 0) {
                window.location.reload();
            }
    		const visibleMagaMenus = menu.querySelectorAll('div.avia_mega_div[style*="opacity: 1"]');
            if (visibleMagaMenus.length > 0) {
                window.location.reload();
            }		
    			} else {
    				const visibleoverlay = document.querySelectorAll('.av-burger-overlay-active');
    				if (visibleoverlay.length > 0) {
                    window.location.reload();
            }
    			}
        }
    });
    

    This checks if the main menu sub-menu, or mega menu, or burger menu overlay is visible, if any of them are then it means the browser back button was used and the browser id displaying a cached page, so the javascript reloads the page to correct.
    If a main menu link is clicked then using the back button doesn’t cause the page to reload, and the same for some Windows browsers like Chrome & Edge.
    This will also not cause any issues with normally navigating the site with menu items, I’m not sure how popular using the browser back button is, since most online stores, banks, and sites where data is input often advise to not use the browser back button, but this will solve the issue if someone does.
    This works for Android, but I don’t have a iPad or iPhone, but I’m pretty sure it will work.
    Best regards,
    Mike

    #1438764

    Hi Mike,
    many, many thanks thanks for this solution. Without your help I would not have been able to solve this problem.

    I have checked everything and it all works correctly now on Windows 11 with Edge and Chrome, on Notepad with Safari and on my Android phone with the Samsung browser.
    Now that everything is working fine you can close this topic.

    Thank you again and a happy Easter
    Sincerely yours,
    Bruno

    #1438767

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Menu problem on iPAD with Safari browser when using back button’ is closed to new replies.