Prevent modal window to close when Enter or Shift-Enter are pressed in an input field

David Noel
Tera Contributor

Hello!

We are using the OOB Ticket Conversations widget, but we are displaying it in a modal window when a chat button is pressed on the portal. The biggest issue is when a user would like to enter a new line in the input field using SHIFT+ENTER the modal window closes. The same thing happens when the user press ENTER the comment is saved but the modal window is also closing, which we don't want to happen. 

Any idea where can I find and modify the code of spModal to prevent this action to happen?

Thanks in advance!

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

Hi David,

On modals you can control Keyboard behaviour (this includes Escape key as well). You can add the option to the Widget instance:

"keyboard": {
		"displayValue": false,
		"value": false
	}

 

In the modal widget it looks for that option:

find_real_file.png

Please refer to: https://stackoverflow.com/questions/20702327/angular-modal-backdrop-issue

 

Let me know if this helped! 🙂

View solution in original post

4 REPLIES 4

Willem
Giga Sage
Giga Sage

Hi David,

On modals you can control Keyboard behaviour (this includes Escape key as well). You can add the option to the Widget instance:

"keyboard": {
		"displayValue": false,
		"value": false
	}

 

In the modal widget it looks for that option:

find_real_file.png

Please refer to: https://stackoverflow.com/questions/20702327/angular-modal-backdrop-issue

 

Let me know if this helped! 🙂

Hi David,
Did the information help?
If you call the spModal from script. You can add backdrop:'static' in the call like this:

spModal.open({
        title: 'Sup?',
        backdrop: 'static'
    });

This will prevent the closing when clicking outside.

 

And to add the keyboard not closing:

spModal.open({
    title: 'Sup?',
    backdrop: 'static',
    keyboard: false;
});

Willem
Giga Sage
Giga Sage

@David Noel is this still an issue? If so, please let us know how we can help?

If not, mark answer as Correct to close the thread.

Mohammad Alhajj
Tera Expert

Hi @David Noel 

 

Please try bellow script it works for me. The problem was with the modal buttons.

 

spModal.open({
    title: 'Hi',
    backdrop: 'static',
    keyboard: false,
    buttons: ['','']; 
});

 

Or, if you want to keep the buttons

spModal.open({
    title: 'Hi',
    backdrop: 'static',
    keyboard: false,
    buttons: [
                {label:'Ok', hide: true},
                {label:'Cancel', hide: true}
            ];
});

 

Please mark my ANSWER as CORRECT and HELPFUL if it helps