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
- Add an icon to a section.
- Configure a Local Action OnClick of the icon at runtime.
- 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
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.