Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Unable to close a Modal window through a local action

SA-42426

Summary



Unable to close a Modal window, through a local action, on clicking the Close (X) icon.


Error Messages



Not Applicable


Steps to Reproduce

  1. Add an icon to a section.
  2. Configure a Local Action OnClick of the icon at runtime.
  3. Click the 'X' button to close the modal window when it opens. The window does not close and the control is on the Cancel button.


Root Cause



A defect in Pegasystems’ code or rules.


Resolution



Perform the following local-change:

Include the following script in the UserWorkForm: <script>
pega.u.d.attachOnload(function(){
pega.ui.Doc.prototype.focusOnModalDialogFirstElement = function(){
if(!(pega.cl && pega.cl.isTouchAble())) {
var firstFocusElem = pega.u.d.getFirstFocusableElement('modalContent');
if(firstFocusElem && firstFocusElem.nodeName == 'TEXTAREA' && firstFocusElem.className.indexOf('PEGACKEDITOR') != -1){
for(var i in CKEDITOR.instances){
if(firstFocusElem.id == CKEDITOR.instances[i].name){
CKEDITOR.instances[i].on('instanceReady', function(){
try{
CKEDITOR.instances[i].focus();
}catch(e){}
});
break;
}
}
}
else if(firstFocusElem){
try{
firstFocusElem.focus();
pega.u.d.fixFocusInIE(firstFocusElem);
}catch(e){}
}
}
/*Add a listener to listen for TAB and restrict the focus within the modal dialog.*/
var modalEl = document.getElementById("modalContent");
pega.util.Event.removeListener(modalEl,"keydown",pega.u.d.restrictFocus);

var firstBoundary = pega.u.d.getFirstFocusableElement('modalContent');
var lastBoundary = pega.u.d.getLastFocusableElement('modalContent');
pega.util.Event.addListener(modalEl,"keydown",pega.u.d.restrictFocus,[firstBoundary,lastBoundary]);
/*BUG-159761:When the modal close icon is focused, focus back on the lastfocusable element*/
if($(lastBoundary).length > 0 && $(lastBoundary)[0].id != 'container_close' && !pega.util.Event.isIE) {
$('#container_close').focusin(function() {$(lastBoundary).focus();})
}
};
},true);
</script>


Published January 12, 2018 - Updated October 8, 2020

Was this useful?

50% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us