Vuepic / vue-datepicker

Datepicker component for Vue 3
https://vue3datepicker.com
MIT License
1.43k stars 142 forks source link

Cannot use with Vuetify since v9 ("Could not find defaults instance") #956

Closed soetz closed 1 month ago

soetz commented 1 month ago

Describe the bug This bug seems very similar to #572. Using any Vuetify component in a VueDatePicker slot prints the error in the console and the datepicker menu doesn’t open.

Here are the errors that I get: [Vue warn]: injection 'Symbol(vuetify:defaults)' not found. 
at <VBtn variant='outlined' > 
at <ActionRow key=3 menu-mount=false multiCalendars=undefined  ... > 
at <DatepickerMenu multiCalendars=undefined modelValue=null modelType=null  ... > Uncaught Error: [Vuetify] Could not find defaults instance
at injectDefaults (chunk-3SA2LMFG.js?v=6b41c1b1:1311:11)
at setup (chunk-3SA2LMFG.js?v=6b41c1b1:1127:24)
at callWithErrorHandling (chunk-PW74NBAW.js?v=6b41c1b1:1676:19)
at setupStatefulComponent (chunk-PW74NBAW.js?v=6b41c1b1:9137:25)
at setupComponent (chunk-PW74NBAW.js?v=6b41c1b1:9098:36)
at mountComponent (chunk-PW74NBAW.js?v=6b41c1b1:6526:7)
at processComponent (chunk-PW74NBAW.js?v=6b41c1b1:6492:9)
at patch (chunk-PW74NBAW.js?v=6b41c1b1:5961:11)
at mountChildren (chunk-PW74NBAW.js?v=6b41c1b1:6203:7)
at mountElement (chunk-PW74NBAW.js?v=6b41c1b1:6116:7)

To Reproduce

  1. Access the minimal reproduction at https://stackblitz.com/edit/vitejs-vite-tqu9lh?file=src%2FApp.vue
  2. Try to open the datepicker menu by clicking the input
  3. Menu doesn’t open + console prints error

Expected behavior The same as with v8: https://stackblitz.com/edit/vitejs-vite-vau6bq?file=src%2FApp.vue The menu opens and the Vuetify components are shown inside.

Desktop & mobile (please complete the following information):

Jasenkoo commented 1 month ago

@soetz It looks like Vuetify is doing some internal overriding on how components render, or in this case if you are using it inside some of their components.

To fix this, pass the config prop with :config={ shadowDom: true } which should resolve the issue.

soetz commented 1 month ago

Thanks @Jasenkoo, this looks like it works. I have one question though: this prop doesn’t actually use shadow DOM directly, right? It just changes how the datepicker renders to make it possible to use it in conjunction with the shadow DOM. Or did I get it wrong?

Jasenkoo commented 1 month ago

@soetz Yes, you are right, no additional changes are made, it just doesn't use slots to pre-calculate position.

soetz commented 1 month ago

Great, thanks again, and thanks for the great library.

olehpryimak1999 commented 5 days ago

Same bug with action-extra slot, thanks a lot for this project. @Jasenkoo