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

Programmatic modal #285

Closed
ldiellyoungl opened this issue Jun 13, 2023 · 6 comments · Fixed by #1319
Closed

Programmatic modal #285

ldiellyoungl opened this issue Jun 13, 2023 · 6 comments · Fixed by #1319
Labels
enhancement New feature or request

Comments

@ldiellyoungl
Copy link

Programmatic modal usage like accept dialog (yes/no)

@ldiellyoungl ldiellyoungl added the enhancement New feature or request label Jun 13, 2023
Copy link
Member

This could be nice indeed, there is something we could do with https://vueuse.org/core/createTemplatePromise/, I'll look into it!

@acidjazz
Copy link
Contributor

requested a similar feature confirmations

@AbdallahAlhaddad
Copy link

AbdallahAlhaddad commented Aug 6, 2023

Hi @benjamincanac

I think we could replace HeadlessUI Dialog with vue-final-modal

Added benefits in addition to providing a Styleless component

  • useModal() composable to manage your modals programmatically.
  • Nested modals support.

What do you think?

Copy link
Member

I'd rather implement the useModal composable ourself and add a <UModals /> container like we do for notifications.

Copy link

Vue-final-modal is also a good option, but I agree with @benjamincanac: his option may be more customizable and may offer better availability for people with limited accessibility.

@noook
Copy link
Collaborator

noook commented Feb 5, 2024

I'm interested in contributing to this, following @benjamincanac 's recommendation.

I'd have a few questions regarding the implementation, and what I have in mind:

I believe OP expects an API like this (types are fictives, I don't know the exact ones but interested to know them):

interface UseModalControls {
  // Optional modal component param would allow chaining Modals
  reveal: (modalComponent?: Component) => Promise<void>
  hide: () => Promise<void>
  isOpen: Ref<boolean>
}

function useModal<T extends Component>(modalComponent: T, props: ComponentProps<T>, modalLifeCycleOptions?: ModalLifeCycleOptions): UseModalControls {}

// modalLifeCycleOptions -> onReveal, onClose ...

Dealing with this composable across multiple components means that we need to persist the state of the current configured modal (selected component, open/close state...). -> Should we use inject/provide (with createInjectionState() or createSharedComposable() for example) to provide the state at the root level when installing the module, and inject in the composable so it is aware of the current state ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants