Currently working with HTML, CSS, and JS (specifically Angular)
- I have a Header menu that contains dropdown sub-menus and sub-sub-menus in desktop view.
- On a PC, the sub-menus appear on hover and clicking on an entry redirects you somewhere.
- Clicking on the main entry leads to a different location - serving as both a link and the trigger for the dropdown menu upon hover.
- Not every root element has a sub-menu.
- There is a separate mobile menu created using media queries for width. However, Tablets in landscape mode display the desktop style, causing some issues.
When testing on tablets (Safari iOS and Chrome for iPad) interesting behavior is observed...
- If an element does not have a dropdown, tapping on it directs you to the link.
- If an element has a dropdown sub-menu,
- The first tap activates the hover effect without triggering the link but reveals the menu.
- A second tap activates the link.
Quite intriguing!
The problem arises when the menus do not disappear upon tapping off them.
- Tapping anywhere on the page itself has no effect (no click-event is raised).
- Tapping on another clickable element clears the menu while triggering the link associated with that element.
Initially, I thought of adding a transparent layer across the page under the menu to bind a click event for clearing the menu. However, I faced difficulties making both the transparent layer and underlying page clickable simultaneously. Check out the challenges encountered here.
Even setting the click event on the body to trigger a bubble up did not work as expected (click event didn't fire.)
Experimented with ngTouch which triggered click events everywhere but disrupted the behavior of opening sub-menus - all links started activating immediately, hindering access to the sub-menus.
Any insights or suggestions would be greatly appreciated! Help needed!