nuxt / ui

A UI Library for Modern Web Apps, powered by Vue & Tailwind CSS.
https://ui.nuxt.com
MIT License
3.4k stars 374 forks source link

[DOCS][UModal] Add emits on documentation #1743

Closed hamonCordova closed 2 weeks ago

hamonCordova commented 2 weeks ago

Description

Today i was trying to find a way how i could know that a modal was closed (when opening programmatically). Then i discovered that existence of onClose emit, wich is fired automatically by the Nuxt UI, but the docs doesn't mention it.

Additional context

No response

noook commented 2 weeks ago

Indeed, IIRC barely no event is documented currently so it's not just for <UModal>

I don't know if this is something planned for the next version, but as of now the best documentation is the code itself regarding events.

Also, note that when opening programmatically, you can add a listener for the close event when you open the modal

hamonCordova commented 2 weeks ago

Also, note that when opening programmatically, you can add a listener for the close event when you open the modal

Could you give an example?

noook commented 2 weeks ago

Sure, you can check this playground: https://stackblitz.com/edit/nuxt-ui-jcyjjx?file=app.vue

The second argument of modal.open are the props and listeners of the components you are revealing. As this component must have <UModal /> as a root component, it "inherits" the props and listeners of <UModal />

You should have autocomplete for those normally: image.png