Closed sparrow-chik-chrk closed 1 month ago
Service' should be imported manually: https://primevue.org/toast/#toast-service
@tugcekucukoglu
I am very glad, of course, that you are closing the issue without looking into the matter.
But still. I am using primevue/nuxt-module.
When I add ToastService, even on the client side, there is an error in the browser console stating that the service is added multiple times.
I'm not even mentioning that adding a plugin to nuxt with ToastService does not solve the issue.
Service' should be imported manually: https://primevue.org/toast/#toast-service
Or provide an example of the configuration for Nuxt that will work.
I would be very grateful.
@tugcekucukoglu @sparrow-chik-chrk
After some investigation I have find out, that Nuxt 3.13.2 is breaking toast. With 3.13.1 everything works as expected.
Describe the bug
Problem:
When using the
@primevue/nuxt-module
, theToast
component does not work correctly unlessautoImport: true
is enabled.useToast()
.useToast().add("Example")
, nothing happens.I verified that
ToastService
is being automatically imported by the module, as trying to manually add a plugin for it results in a console message indicating that it is already registered.For testing purposes, I set the
components
,directives
, andcomposables
options toinclude: "*"
, but the issue persisted.However, when
autoImport: true
is enabled, everything works as expected, anduseToast().add("Example")
starts functioning properly.It seems that the auto-import is handling something outside of the defined
components
,directives
, andcomposables
configurations, which is necessary forToast
to work.Expected Behavior:
It should be possible to manually configure the import of components, directives, and composables for the
Toast
component to work without needing to enableautoImport: true
.Actual Behavior:
useToast().add()
does not work unlessautoImport: true
is enabled, even when all necessary components, directives, and composables are manually included.Environment:
Additional Context:
The problem seems to be that
autoImport
is doing more than just importingcomponents
,directives
, andcomposables
. There is likely something else being auto-imported that is necessary for theToast
component to function properly. The current manual import configuration does not cover whatever this missing part is.I would appreciate a way to manually import everything necessary for the
Toast
component without relying onautoImport: true
.Thanks!
Reproducer
https://stackblitz.com/edit/primevue-nuxt-issue-template-jykhii
PrimeVue version
4.0.7
Vue version
3.x
Language
TypeScript
Build / Runtime
Nuxt
Browser(s)
Chrome 90
Steps to reproduce the behavior
@primevue/nuxt-module
.autoImport: false
and manually include all components, directives, and composables:Toast
component and calluseToast().add()
:Observe that nothing happens when calling
toast.add()
, even though the component is rendered anduseToast
is recognized by TypeScript.Change
autoImport: true
in the module configuration and see thatuseToast().add()
now works as expected.Expected behavior
No response