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



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.


Perform the following local-change:

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

var firstBoundary = pega.u.d.getFirstFocusableElement('modalContent');
var lastBoundary = pega.u.d.getLastFocusableElement('modalContent');
/*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();})

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