#Disable key Esc

1 messages · Page 1 of 1 (latest)

south patrol
#

When I open some popup modal and I press the Esc key I close the modal. How to disable the Esc key? How to override Esc key press event in the popup modal? The Quick dismiss is false

opaque chasmBOT
#

Hello! I'm Appy, your Appsmith support bot.

To disable the Esc key for closing a modal when the "Quick Dismiss" property is set to false, you can use a JavaScript function to override the default behavior. Here?s how you can do it:

  1. Create a JSObject: Go to the JSObjects section and create a new JSObject.
  2. Add a Function: In your JSObject, add a function that listens for the keydown event and prevents the modal from closing if the Esc key is pressed.

Here's a sample code snippet you can use:

export default {
overrideEsc: () => {
document.addEventListener('keydown', function(event) {
if (event.key === "Escape") {
event.stopPropagation();
}
}, true);
}
}

  1. Invoke the Function: You need to invoke this function when the modal is opened. You can do this by adding a script to call this function in the onOpen property of the modal.

{?{ JSObject1.overrideEsc() }?}

This setup will ensure that pressing the Esc key does not close the modal. If you have any more questions or need further assistance, feel free to ask!

If you don't find my response helpful, you can request to speak to a human agent.

south patrol
#

in this function is a bug because 'document' is not defined

opaque chasmBOT
#

Apologies for the confusion earlier. In Appsmith, direct DOM manipulation or access (like using document) is not supported due to the abstraction layer provided by the platform for security and maintainability.

To disable the Esc key for closing a modal in Appsmith, you should ensure that the "Quick Dismiss" property of the modal is set to false. This property prevents the modal from closing when the user clicks outside of it or presses the Esc key.

If "Quick Dismiss" is already set to false and the modal is still closing with the Esc key, this might be unexpected behavior. In such cases, it's recommended to check for any other scripts or configurations that might be influencing this behavior. If the issue persists, it might be beneficial to reach out to Appsmith support directly for a more in-depth investigation.

If you need further assistance or have other questions, feel free to ask!

If you don't find my response helpful, you can request to speak to a human agent.

south patrol
#

I request to speak to a human agent becaouse your anwser is not fine

opaque chasmBOT
#

Someone from our team will reach out to you on this thread. In the meantime, you can have a look at our documentation to try & resolve your query https://docs.appsmith.com?utm=bot

Organizations build internal applications such as dashboards, database GUIs, admin panels, approval apps, customer support tools, etc. to help improve their business operations. Appsmith is an open-source developer tool that enables the rapid development of these applications. You can drag and drop pre-built widgets to build UI. Connect securely...

south patrol
#

I've seen the documentation before

#

I have to speak to a human agent

opaque chasmBOT
#

Hello! I'm Amelia with Appsmith Support. ?
You can add an action in the onClose event of the Modal widget. The action will be triggered if you click the Close button, click the X in the upper right of the modal, or if you press the ESC key. Let me know if this helps.

severe rune
south patrol
#

quick dismiss should be on or off?

opaque chasmBOT
#

If Quick dismiss is on, then clicking outside the Modal will close it and trigger the action set in the onClose event. If Quick dismiss is off, then clicking outside of the modal will have no effect - the modal will stay open.

south patrol
#

It doesn't work, I can close the modal when I pressed the Esc key

south patrol
#

It doesn't work, I can close the modal when I pressed the Esc key. I want to off the Esc key