Vuesax: vs-popup prevent close when click out

Created on 24 Sep 2019  路  3Comments  路  Source: lusaxweb/vuesax

Is your feature request related to a problem? Please describe.
needed a popup option to prevent closing the popup when clicked outside

Describe the solution you'd like
When a popup option [disable clickoutside] is set, the user won't be able to close the popup outside the modal/popup. Only close button can close the popup

Most helpful comment

I agree this functionality would be helpful. The behavior of a popup is slightly different than a dialog, so being able to manage when they can be closed provides more flexibility.

All 3 comments

You can use the vs-dialog for users not being able to close dialog

I agree this functionality would be helpful. The behavior of a popup is slightly different than a dialog, so being able to manage when they can be closed provides more flexibility.

Extend the VsPopup component, add custom closeOnClickOutside prop and add condition to close method like so:

<script>
export default {
props: {
    ...,  // others props
    closeOnClickOutside: {
      default: true,
      type: Boolean,
},
methods: {
close(event, con) {
      if (con) {
        if (
          event.target.className &&
          event.target.className.indexOf &&
          event.target.className.indexOf("vs-popup--background") != -1 &&
          this.closeOnClickOutside // add this condition
        ) {
          this.$emit("update:active", false)
          this.$emit("close", false)
        } else if (!this.buttonCloseHidden && event.srcElement == this.$refs.btnclose.$el) {
          this.$emit("update:active", false)
          this.$emit("close", false)
        }
      }
    },
}
}
</script>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jsinhSolanki picture jsinhSolanki  路  3Comments

danyakov picture danyakov  路  3Comments

alexflorea2 picture alexflorea2  路  4Comments

grali picture grali  路  4Comments

bigperson picture bigperson  路  3Comments