floating-vue icon indicating copy to clipboard operation
floating-vue copied to clipboard

TypeError: Cannot destructure property 'popperId' of 'undefined' as it is undefined.

Open bufgix opened this issue 2 years ago • 13 comments

I'm migrating from Vue2 to Vue3. I changed the package name v-tooltip => floating-vue and I just use v-tooltip directive so i just register the directive like:

import { VTooltip } from 'floating-vue'
   
//...
app.directive('tooltip', VTooltip)

and I'm getting error when I use directive

 <h3 v-tooltip="'test popover'"  v-text="$t('Welcome Back')" />
Uncaught (in promise) TypeError: Cannot destructure property 'popperId' of 'undefined' as it is undefined.
resim

Some warnings before throwing this error resim

Im on the migration process and i use @vue/compat (Migration Build) on Vue 2 mode.

floating-vue version is ^2.0.0-beta.20

bufgix avatar Dec 29 '22 11:12 bufgix

did you figure out the issue?

junaidshad avatar Feb 16 '23 12:02 junaidshad

did you figure out the issue?

Nope. I cancelled vue 3 migration still using v-tooltip for vue 2 :( @junaidshad

bufgix avatar Feb 17 '23 21:02 bufgix

it looks like we will encounter this error if we use MODE: 2 in @vue/compat to remove the error, use MODE: 3 in compat cofiguration

import { configureCompat } from 'vue'

...

export default {
  install (app) {
    configureCompat({
      MODE: 3
    })
    app.directive('tooltip', VTooltip)
    app.directive('close-popper', VClosePopper)
  })
}

jarooda avatar Feb 23 '23 02:02 jarooda

@jarooda For me it didn't work even with MODE: 3.... it just worked after i removed the @vue/compat migration build package. Most of the third party dependencies does not support vue compat migration build.

junaidshad avatar Feb 23 '23 04:02 junaidshad

Anybody have this working yet?

Hitting roadblocks on our migration to Vue 3 with this.

Also made a minimal repro at https://stackblitz.com/edit/node-whjkss?file=src/Playground.vue

Hoping someone can point me in the right direction 🙏

vgshenoy avatar Mar 17 '23 12:03 vgshenoy

@vgshenoy No, No luck in getting it work under the @vue/compat migration build so far.

junaidshad avatar Mar 21 '23 04:03 junaidshad

as a workaround we've been using the vue 2 version of the library, which works with vue 3 + compat mode

it would be really great to see a fix for this though!

callumacrae avatar May 09 '23 09:05 callumacrae

as a workaround we've been using the vue 2 version of the library

This doesn't work for us; we get this error instead:

Cannot read properties of undefined (reading 'theme')
TypeError: Cannot read properties of undefined (reading 'theme')
    at Proxy.eval (webpack-internal:///./node_modules/floating-vue/dist/floating-vue.es.js:226:35)
    at resolvePropValue (webpack-internal:///./node_modules/@vue/compat/dist/vue.esm-bundler.js:7298:53)
    at setFullProps (webpack-internal:///./node_modules/@vue/compat/dist/vue.esm-bundler.js:7274:20)
    at initProps (webpack-internal:///./node_modules/@vue/compat/dist/vue.esm-bundler.js:7097:3)
    at setupComponent (webpack-internal:///./node_modules/@vue/compat/dist/vue.esm-bundler.js:10489:3)
    at mountComponent (webpack-internal:///./node_modules/@vue/compat/dist/vue.esm-bundler.js:8801:7)
    at processComponent (webpack-internal:///./node_modules/@vue/compat/dist/vue.esm-bundler.js:8766:9)
    at patch (webpack-internal:///./node_modules/@vue/compat/dist/vue.esm-bundler.js:8254:11)
    at ReactiveEffect.componentUpdateFn [as fn] (webpack-internal:///./node_modules/@vue/compat/dist/vue.esm-bundler.js:8913:11)
    at ReactiveEffect.run (webpack-internal:///./node_modules/@vue/compat/dist/vue.esm-bundler.js:652:19)

Presumably because this is no longer defined in the props default function, and trying to directly copy a reference to this.$props sidesteps the shim

alecgibson avatar Jul 31 '23 13:07 alecgibson

Okay did some more digging using vue@3 with floating-vue@2.

I don't think this library plays nicely with the compatibility build and the render function break.

The library works for us if we disable the RENDER_FUNCTION compatibility flag:

import {configureCompat} from 'vue';

configureCompat({
  RENDER_FUNCTION: false,
});

alecgibson avatar Jul 31 '23 15:07 alecgibson

To solve this problem, I had to create myself a directive that does the tooltip behavior, using floating-ui/dom.

After migrating to vue 3, he intends to remove this created directive and use the one from the component.

luisrossi avatar Aug 07 '23 16:08 luisrossi

did you figure out the issue?

@junaidshad hi buddy how did you manage to solve this issue when you were migrating CS back then?

omairmir avatar Dec 15 '23 07:12 omairmir

@omairmir Hey! Back then, we discarded this package and switched to vue-tippy plugin (https://www.npmjs.com/package/vue-tippy).

appContainer.use(VueTippy, { directive: 'tooltip', arrow: true })

This is how it was used. This way we didn't had to change the v-tooltip directive inside vue components.

junaidshad avatar Dec 16 '23 04:12 junaidshad