Control the closeOnEscape Dialog in a webItem dialog


We are developing a hybrid app using Forge and Connect, and have added a webItem in the Connect atlassian-connect.json. This webItem is located in the issue navigator and opens a Dialog where our application runs.

However, we are encountering a problem: pressing the Escape key closes the Dialog entirely. We believe this is the default behaviour, but we would like to be able to control it. We have tried setting the closeOnEscape option to false in the dialog settings, but it did not work.

Is there any way to control this behaviour?

Thank you very much.
Best regards,


Hi @david.gonzalez,
Have you tried this in a regular Connect app to check whether the fact the app is on Forge has anything to do with it?

And would you mind including a snippet of the relevant parts of the descriptor and javascript code to aid in reproducing this?

Are you handling the “close” event? Dialog


Yes, we have tried this in a regular Connect app, and unfortunately, we are experiencing the same result. We have also tested all the available options for AP.dialog in the descriptor, but nothing has worked so far. Additionally, we attempted to detect when the Escape key is pressed using JavaScript, but the iframe closes immediately, and we are unable to intervene.

Of course, here is the snippet of our code in atlassian-connect.json:

         "webItems": [
                "url": "/views/exportation-view",
                "location": "jira.navigator.pluggable.items",
                "weight": 10,
                "key": "exporter-dashboard-top-menu-item",
                "name": {
                    "value": "Exporter"
                "tooltip": {
                    "value": "Exporter"
                "icon": {
                    "width": 16,
                    "height": 16,
                    "url": "public/img/icon/logo.svg"
                "target": {
                    "type": "dialog",
                    "options": {
                        "chrome": false,
                        "height": "500px",
                        "width": "400px"
        "dialogs": []

And this is the snippet of forge application:

    - url: /views/exportation-view
      location: jira.navigator.pluggable.items
      weight: 10
      key: exporter-dashboard-top-menu-item
        value: Exporter
        value: Exporter
        width: 16
        height: 16
        url: img/icon/logo.svg
        type: dialog
          chrome: false
          height: 500px
          width: 1600px
  jira:dialogs: [ ]

Thank you!

I have used the AP.dialog in a Confluence app and there the closeOnEscape works. I assume that the AP library is more or less the same in Jira and Confluence Connect apps, so it should also work in your case.

There is, however, one thing you have to be aware of. When the dialog is opened, its iframe doesn’t get the keyboard focus automatically. This means when you press the ESC key, the event will be created in the top frame. Confluence and Jira probably define an event listener to close the current dialog on ESC. The closeOnEscape setting only operates in the iframe context. When it is set to true, the AP library will add an key event listener inside the iframe to close the dialog on ESC. To fix your issue you’ll have to move the keyboard focus to your dialog iframe for example with window.focus().

1 Like

In our case, we do not launch the Dialog from the jira AP object, but it is loaded from the webItem when we click on the it. This webItem is located in the apps menu of the issue navigator.

I tried the window.focus() because we don’t tested before, but It doesn’t work.