Currently, I am working on creating a unique responsive navigation system that transforms into a 100% width pulldown menu for mobile devices. To achieve this functionality, I have implemented some JavaScript code that hides any open sub-menu items when the window is resized to a new breakpoint (typically at 768px). However, I have encountered an issue where if a sub-menu is opened in the mobile view and then the window is suddenly resized, the hover effect stops working and the sub-menu items fail to appear on the larger screen size.
If you would like to see a simplified version of my navigation setup, you can check out this JSFiddle: https://jsfiddle.net/5h5bhwu4/2/
The section of JavaScript that I suspect may be causing the problem is as follows:
if (w > 768) {
$("#nav > li > ul").hide();
}
When testing, I noticed that if I click on the first menu item in the small screen size, then resize the window, the same sub-menu fails to display when hovering over the parent item. However, if I start at a larger screen size or do not open the sub-menu in the small screen view, everything works correctly. It seems like there may be an issue with the JavaScript logic preventing the sub-menu from appearing properly.