Add apparent way to capture emits when using $q.dialog #13150
-
As of now, there isn't an ergonomic way to capture custom events emitted from dialogs when using $q.dialog. In the past, it was recommended to pass functions as props to the dialog as a workaround. This is unnecessary and becomes really messy when using Quasar with TypeScript and Vue 3's composition API. Example of the pain point: I have a dialog created thru $q.dialog() that is used to set some settings for a game board. Right now, it can emit whatever events it wants, but you can only set callbacks to quasar dialog's default emits, making custom emits basically useless. Following past recommendations, you end up with this: (in the dialog component)
BoardSettings is just a basic object that holds some numbers and booleans. In the component that hosts the dialog:
Besides not working as intended, it's not really obvious what I need to type things. Plus, it's unnecessary, and does not make it obvious where behavior is supposed to be triggered. I have two proposals for allowing parent components to listen to custom events from dialogs simple. Say you define your emits like this:
Those first 2 are the default emits provided and hooked by quasar. The third one is a custom emit that I would like to use. I have thought of 2 different ways to do this: Option 1: Dialog option - kind of Options API-flavored:
Option 2:
Thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
The dialog can only have two exit points: onCancel and onOk And if using typescript it would be really nice because you can use a discriminant in the payload |
Beta Was this translation helpful? Give feedback.
-
I found this while searching a related issue. In case anyone comes along later on this is now possible using Can mark this one as answered I think. |
Beta Was this translation helpful? Give feedback.
I found this while searching a related issue. In case anyone comes along later on this is now possible using
componentProps
as shown here in the docs: https://quasar.dev/quasar-plugins/dialog#invoking-custom-componentCan mark this one as answered I think.