Akryum / floating-vue

💬 Easy tooltips, popovers, dropdown, menus... for Vue
https://floating-vue.starpad.dev/
MIT License
3.34k stars 337 forks source link

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

Open bufgix opened 1 year ago

bufgix commented 1 year ago

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

junaidshad commented 1 year ago

did you figure out the issue?

bufgix commented 1 year ago

did you figure out the issue?

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

jarooda commented 1 year ago

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)
  })
}
junaidshad commented 1 year ago

@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.

vgshenoy commented 1 year ago

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 🙏

junaidshad commented 1 year ago

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

callumacrae commented 1 year ago

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!

alecgibson commented 1 year ago

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 commented 1 year ago

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,
});
luisrossi commented 1 year ago

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.

omairmir commented 11 months ago

did you figure out the issue?

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

junaidshad commented 11 months ago

@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.