vue-final / vue-final-modal

🍕Vue Final Modal is a tiny, renderless, mobile-friendly, feature-rich modal component for Vue.js.
https://vue-final-modal.org
MIT License
864 stars 95 forks source link

Documentation for useModal events is missing #385

Closed Offlein closed 7 months ago

Offlein commented 10 months ago

The documentation for the UseModal() composable makes it clear that the attrs object can contain custom event listeners, but does not explain a fundamental aspect of VFM's expectations.

The question seems to have come up a few times in the Issues here, and you answer it definitively here that event listeners must be prefixed with on, although it's still a little vague. Especially since in this comment I believe you are typo'ing and saying that the event emitted should be onCloseModal

It might save you some trouble to add to the documentation something like this:

  ...
  attrs: {
    // Bind props to the modal component (VueFinalModal in this case).
    clickToClose: true,
    escToClose: true,
    // Bind events to the modal component (VueFinalModal in this case).
    // Any custom event can be listened for when prefixed with "on", e.g. "onEventName".
    onBeforeOpen() { /* on before open */ },
    onOpened() { /* on opened */ },
    onBeforeClose() { /* on before close */ },
    onClosed() { /* on closed */ },
    onCustom() { /* listens for an emitted event with name "custom" */ }
    onSomethingElse() { /* listens for an emitted event with name "somethingElse" */ }
  },
  ...

I'm actually not even 100% sure that an event "somethingElse" would come in via "onSomethingElse" (versus "onSomethingelse" maybe?), but I hope my overall point is clear.

Love the library. Thanks for all you do!

hunterliu1003 commented 7 months ago

@Offlein As you can see in the video below:

https://github.com/vue-final/vue-final-modal/assets/15190246/5d8e877e-634d-49cc-a349-e67d76283c73

You'll see all of the props and events you can use in <VueFinalModal> by vscode's auto completion. I am sure that the TS user can have this DX, but not sure about the js users.

Offlein commented 7 months ago

@hunterliu1003 Thank you for the reply. I don't believe I had that intellisense in my JetBrains IDE -- but it's also possible I just missed it!

I see the documentation is updated too! Looks great to me! Much appreciated.