xiaoluoboding / vue-command-palette

⌨️ A fast, composable, unstyled command palette interface for Vue.
https://vue-command-palette.robertshaw.id/
MIT License
544 stars 27 forks source link

[Feature Request] Support close dialog when click mask #10

Open Deuscx opened 1 year ago

Deuscx commented 1 year ago

Is it able to support close-on-click-model like element-plus dialog https://element-plus.org/en-US/component/dialog.html#attributes

image
thara003 commented 1 year ago

Hi @xiaoluoboding,

I think I found a way to solve this problem using onClickOutside function.

Can I contribute the solution to the project?

gsabater commented 7 months ago

Another solution would be adding a listener on a parent element like the mask. You can set this on the component where the palette is mounted.

This is what i did in my repository

document.body.addEventListener('click', (event) => {
  if (event.target.matches('[command-dialog-mask]')) {
    if (this.ui.show) this.hide()
  }
})