Bootstrap modal closing while press ENTER key in textarea element

Aviv S_
Tera Contributor

Hi guys

I have an SP modal widget which contain textarea element, in this field the user should have the ability to break-line by press enter key, but in this case the modal is closing.

I see that if I use f12 with debugger is behave OK, also if I add any alert dialog in the controller.
I already try to "catch" the ENTER key event and put 'return false' or use the method 

preventDefault()
but nothing help, even the HI supporters not have any good idea.

Can you advise any WA for it?
I know this is not ServiceNow pure issue but I hope you could assist with workaround for this.

Tnx

1 ACCEPTED SOLUTION

Mohammad Alhajj
Tera Expert

Hi @avivs 

 

Please try bellow script it works for me. The problem was with the modal default 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

View solution in original post

9 REPLIES 9

Mohammad Alhajj
Tera Expert

Hi @avivs 

 

Please try bellow script it works for me. The problem was with the modal default 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

 

tnx for your response.
Indeed it fix the issue with the closing modal (tnx for that!) but it seems now the user does not have any ability to press enter key and break-line, as I mentioned this is textarea element for multi lines.
 

tnx for your response.
Indeed it fix the issue with the closing modal (tnx for that!) but it seems now the user does not have any ability to press enter key and break-line, as I mentioned this is textarea element for multi lines.

It is working fine with me. 

find_real_file.png

Try to remove this:

keyboard: false,

 

Please mark my ANSWER as CORRECT and HELPFUL if it helps

 

Aviv S_
Tera Contributor

@Mohammad Alhajjaj thank you ! 🙂