AP Dialog

151 views
Skip to first unread message

Mateusz Czyrny

unread,
Oct 5, 2016, 9:22:28 AM10/5/16
to Atlassian Connect Dev
Hi 
I have a problem
In my plugin I used few dialog all is created by AP.require('dialog',...)

When I open first dialog and click cancel and and then I open the second dialog and click submit I will get response 
"action1"
"action2"

It looks like the cancel button didn't close the dialog but only hide it and its listener is still listening on "close" event

Implementation below :



First dialog
AP.require('dialog', function (dialog) {
var newDialog = dialog.create({
key: 'somekey',
chrome: true,
});
dialog.getButton('submit').disable();

newDialog.on("close", function (result) {
console.log('action1')
    });
}); Second dialog
AP.require('dialog', function (dialog) {
var newDialog = dialog.create({
key: 'somekey1',
chrome: true,
});
dialog.getButton('submit').disable();

newDialog.on("close", function (result) {
console.log('action2')
});
});

In atlassian-connect.json

"generalPages":{
{
"url": "/url2",
"key": "somekey",
"name": {
"value": "Dialog2"
},
"location": "none"
},
{
"url": "/url1",
"key": "somekey1",
"name": {
"value": "Dialog1"
},
"location": "none"
},
}

Khanh Nguyen

unread,
Oct 5, 2016, 8:37:06 PM10/5/16
to Atlassian Connect Dev
Hi Mateusz,

Unfortunately there is a strange bug where closing the dialog with the submit and cancel buttons does not emit the correct close event. We are aware of this issue and have already made a fix for this in the new version of the Atlassian Connect JavaScript API that is due to be released in near future.

For now, the known workaround for this problem would be to bind the click event on the cancel button and then manually call dialog.close in the dialog frames.

Please add the following script to your /url1 and /url2 pages:

AP.require('dialog', function(dialog) {
  dialog
.getButton('cancel').bind(function(){
    dialog
.close();
 
});
});

I hope this helps. 
Reply all
Reply to author
Forward
0 new messages