Vue-js-modal: Distinguish between "handleBackgroundClick" and "esc.keyup event"

Created on 20 May 2020  路  8Comments  路  Source: euvl/vue-js-modal

Problem:

I want to close modal by clicking on the background BUT not be closed by pressing ESC.
I found this code.

if (this.clickToClose) {
  window.addEventListener('keyup', this.handleEscapeKeyUp)
}

Can provide something like closeOnPressEscape instead of it ? Thanks.

Version:

1.3.33

Example & screenshots:

I have checked stackoverflow for solutions and 100% sure that this issue is not not related to my code.

question stale

Most helpful comment

I am also interested in this feature. I have some rare cases, like wait dialogs, which should not be closed by ESC key.
Is it possible to:

  • Add property closeOnPressEscape, which is by default true. By default, the dialog will be closed, when ESC is pressed. However, with this property we can override this functionality.
  • Add a link in documentation for this property to W3C standards, indicating that such behavior is discouraged.

If this is approved, I can try to implement this feature and make a pull request.

All 8 comments

Closing modals through escape is w3c requirement for a11y, see here in the keyboard support section: https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/dialog.html

I use codemirror.js in the modal and use escape to exit full-screen editing. Modal was also closed together. Is there any way to solve this problem?

I am also interested in this feature. I have some rare cases, like wait dialogs, which should not be closed by ESC key.
Is it possible to:

  • Add property closeOnPressEscape, which is by default true. By default, the dialog will be closed, when ESC is pressed. However, with this property we can override this functionality.
  • Add a link in documentation for this property to W3C standards, indicating that such behavior is discouraged.

If this is approved, I can try to implement this feature and make a pull request.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

I also need the property @avmalyutin mentioned above. My use case is showing a modal while an ajax request finishes. I don't want users interacting with the page before the request finishes or times out. Does anyone have any workarounds?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed.

Feature Request:
I need closeOnPressEscape and closeOnClickBackground properties.
These props might be boolean type and the default is true.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smholsen picture smholsen  路  4Comments

alex3683 picture alex3683  路  4Comments

ar53n picture ar53n  路  4Comments

uptownhr picture uptownhr  路  4Comments

dland512 picture dland512  路  4Comments