Skip to content

Key-event "esc" without focus on modal #25

@claudio147

Description

@claudio147

Is there a reason why the key-event for "escape" just works if the user first clicks inside the modal? I think it would be better if you have a global key event listener which closes you the latest modal.

Something like:

mounted() {
      VuedalsBus.$on('opened', (modal) => {
        if (modal.options.escapable) {
          document.addEventListener('keydown', function dismissModal(event) {
            if (event.keyCode === 27) {
              VuedalsBus.$emit('close');
              document.removeEventListener('keydown', dismissModal, true);
            }
          }, true);
        }
      });
    },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions