vue-lazy-hydration icon indicating copy to clipboard operation
vue-lazy-hydration copied to clipboard

@click not working inside LazyHydrate

Open gutisalex opened this issue 3 years ago • 2 comments
trafficstars

Is there a reason why @click listener not working when they are sitting in a component wrapped with LazyHydrate? I have a Navigation which has Navigationitems fetched from an API. First time routing to the page everything works fine. After pagerefresh it doesnt... any idea?

gutisalex avatar Mar 17 '22 19:03 gutisalex

Hi @gutisalex, I faced with the same issue

The reason of issue was that I used <LazyHydrate on-interaction> which is the same as <LazyHydrate on-interaction="focus"> Focus is used by default

Try to use <LazyHydrate on-interaction="click">

b-karapet avatar May 19 '22 08:05 b-karapet

I had the same problem - indeed 'click' made it hydrate, but didn't call the @click callback.

  • On mobile - adding "touchstart" helps
  • On desktop - adding "mousedown" helps (or "mouseover")

So if you have the same problem with @click:

<LazyHydrate :on-interaction=["click", "focus", "touchstart", "mousedown"]>

or

import { hydrateOnInteraction } from 'vue-lazy-hydration';
export default {
  components: {
    ComponentName: hydrateOnInteraction(() => import(
      '~/components/path/ComponentName.vue'
    ), {event: ['click', 'focus', 'touchstart', 'mousedown']}),
  },
}

neatcoding avatar Jun 19 '23 08:06 neatcoding