Site logo

Archived topic

Clicking the arrow on menu parent on mobile Chrome does not work

21 replies · Started by Sebastien on August 10, 2020

Viewing posts 16–22 of 22

Thanks for getting back to me Leo, I'll check with them.

Hi guys,

So I contacted my hosting support team and they confirmed they can load the URLs from this subdomain without hitting a cache. Could you please try again and let me know?

Many thanks
Sebastien

Last update: I found what is causing the issue. I started disabling all the GP modules to see if it would make a difference with the hovering functionality. And when I disabled the Elements module, the menu hovering started working again. After further investigation, it is because of one element JS code I implemented to use passive listeners and improve scrolling performance (as per Google PageSpeed recommendations). And I basically used the code linked from this thread:

https://generatepress.com/forums/topic/passive-listeners-to-improve-scrolling-performance/

The code being:

<script type="text/javascript">
(function() {
  var supportsPassive = eventListenerOptionsSupported();  

  if (supportsPassive) {
    var addEvent = EventTarget.prototype.addEventListener;
    overwriteAddEvent(addEvent);
  }

  function overwriteAddEvent(superMethod) {
    var defaultOptions = {
      passive: true,
      capture: false
    };

    EventTarget.prototype.addEventListener = function(type, listener, options) {
      var usesListenerOptions = typeof options === 'object';
      var useCapture = usesListenerOptions ? options.capture : options;

      options = usesListenerOptions ? options : {};
      options.passive = options.passive !== undefined ? options.passive : defaultOptions.passive;
      options.capture = useCapture !== undefined ? useCapture : defaultOptions.capture;

      superMethod.call(this, type, listener, options);
    };
  }

  function eventListenerOptionsSupported() {
    var supported = false;
    try {
      var opts = Object.defineProperty({}, 'passive', {
        get: function() {
          supported = true;
        }
      });
      window.addEventListener("test", null, opts);
    } catch (e) {}

    return supported;
  }
})();
</script>

If you have any suggestions to make this code compatible with the hovering functionality on mobile, I would really appreciate it.

Many thanks
Sebastien

Hi there,

so the passive listeners warning is related to the WP core bug regarding the comments link. Which is something they have yet to resolve. And although the code that user provided works to remove that error we don't have a solution that stops it from breaking other elements.

Hi David, thanks for this. I've disabled the code for now.

Sorry we couldn't be of more assistance.

This archived topic is closed to new replies.