Skip to content

Feature: Allow disabling of modal close on Esc key. #232

Closed
@tmorehouse

Description

@tmorehouse

Similar to disable close on clicking the backdrop, it would be nice to be able to disable closing of the modal by pressing ESC.

As well, could you not use @keyup.esc on the modal div to detect if the ESC key was pressed in while the modal was open (rather than binding the esc key detection on the document element?

<div key="modal" :id="id"
     v-show="visible"
     :class="['modal',{fade :fade}]"
     @click="onClickOut($event)"
     @keyup.esc="onEsc($event)"
>
export default {
  ...
  props {
    ...
    closeOnEsc: { type: Boolean, default: true },
    ...
  },
  methods {
    ...
    onEsc(e) {
      if (this.visible && this.closeOnEsc) {
        this.hide();
      }
    },
    ...
  },
  ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions