Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamicDialog: Emits events from modal components doesn't work #5674

Open
evdevel opened this issue May 1, 2024 · 1 comment
Open

DynamicDialog: Emits events from modal components doesn't work #5674

evdevel opened this issue May 1, 2024 · 1 comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@evdevel
Copy link

evdevel commented May 1, 2024

Describe the bug

There is Events section in docs for the DynamicDialog.
We have example with providing two emit events

const emit = defineEmits(['onCancel', 'onSave'])

But it doesn't work. Right now works only one emit - onClose.
May be we have mistake in the documentation and there is a right way to write own emts.

Reproducer

https://stackblitz.com/edit/mkfekr?file=src%2FApp.vue

PrimeVue version

3.52.0

Vue version

3.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

I expect ability to write own emit as I see in documentation.

@evdevel evdevel added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label May 1, 2024
@marcopixel
Copy link

I've had also this and a similar issue yesterday and i've dug a bit deeper and found multiple reason for this issue:

  • The documentation is missing the emits object at the code example
    That one was a easy to find, it's just simply missing in the documentation and needs to be added.

  • Vue event listeners are passed as props with an on Prefix but emit it on the child component side
    I've looked deeper into the code and noticed that the emits are directly bound via v-bind and this applies the emits only if they have the on prefix. Otherwise everything else is just passed as a props directly to the child event and thus not properly bubbling up the event. Also you have to remove the on inside the child component otherwise it will not work.

I've adjusted your code here: https://stackblitz.com/edit/mkfekr-utlr3a?file=src%2FApp.vue

Also since this was suboptimal in my opinion i've decided to make a pull request (#5679) which makes DynamicDialog a lot more flexible and also adjusted how emits are added to the child component 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

2 participants