Fossil SCM
/chat: shift-enter when in preview mode now switches back to message list mode if the input field is empty. It was previously only possible to switch back via button or sending a message.
Commit
79995e13552cab0d047d3900717942dbe117c24ca2e91741863189edbb5a87b2
Parent
13fabf3f4d87d00…
1 file changed
+9
-1
+9
-1
| --- src/fossil.page.chat.js | ||
| +++ src/fossil.page.chat.js | ||
| @@ -1199,11 +1199,19 @@ | ||
| 1199 | 1199 | const inputWidgetKeydown = function(ev){ |
| 1200 | 1200 | if(13 === ev.keyCode){ |
| 1201 | 1201 | if(ev.shiftKey){ |
| 1202 | 1202 | ev.preventDefault(); |
| 1203 | 1203 | ev.stopPropagation(); |
| 1204 | - Chat.e.btnPreview.click(); | |
| 1204 | + /* Shift-enter will run preview mode UNLESS preview mode is | |
| 1205 | + active AND the input field is empty, in which case it will | |
| 1206 | + switch back to message view. */ | |
| 1207 | + if(Chat.e.currentView===Chat.e.viewPreview | |
| 1208 | + && !Chat.e.inputCurrent.value){ | |
| 1209 | + Chat.setCurrentView(Chat.e.viewMessages); | |
| 1210 | + }else{ | |
| 1211 | + Chat.e.btnPreview.click(); | |
| 1212 | + } | |
| 1205 | 1213 | return false; |
| 1206 | 1214 | }else if((Chat.e.inputSingle===ev.target) |
| 1207 | 1215 | || (ev.ctrlKey && Chat.e.inputMulti===ev.target)){ |
| 1208 | 1216 | /* ^^^ note that it is intended that both ctrl-enter and enter |
| 1209 | 1217 | work for single-line input mode. */ |
| 1210 | 1218 |
| --- src/fossil.page.chat.js | |
| +++ src/fossil.page.chat.js | |
| @@ -1199,11 +1199,19 @@ | |
| 1199 | const inputWidgetKeydown = function(ev){ |
| 1200 | if(13 === ev.keyCode){ |
| 1201 | if(ev.shiftKey){ |
| 1202 | ev.preventDefault(); |
| 1203 | ev.stopPropagation(); |
| 1204 | Chat.e.btnPreview.click(); |
| 1205 | return false; |
| 1206 | }else if((Chat.e.inputSingle===ev.target) |
| 1207 | || (ev.ctrlKey && Chat.e.inputMulti===ev.target)){ |
| 1208 | /* ^^^ note that it is intended that both ctrl-enter and enter |
| 1209 | work for single-line input mode. */ |
| 1210 |
| --- src/fossil.page.chat.js | |
| +++ src/fossil.page.chat.js | |
| @@ -1199,11 +1199,19 @@ | |
| 1199 | const inputWidgetKeydown = function(ev){ |
| 1200 | if(13 === ev.keyCode){ |
| 1201 | if(ev.shiftKey){ |
| 1202 | ev.preventDefault(); |
| 1203 | ev.stopPropagation(); |
| 1204 | /* Shift-enter will run preview mode UNLESS preview mode is |
| 1205 | active AND the input field is empty, in which case it will |
| 1206 | switch back to message view. */ |
| 1207 | if(Chat.e.currentView===Chat.e.viewPreview |
| 1208 | && !Chat.e.inputCurrent.value){ |
| 1209 | Chat.setCurrentView(Chat.e.viewMessages); |
| 1210 | }else{ |
| 1211 | Chat.e.btnPreview.click(); |
| 1212 | } |
| 1213 | return false; |
| 1214 | }else if((Chat.e.inputSingle===ev.target) |
| 1215 | || (ev.ctrlKey && Chat.e.inputMulti===ev.target)){ |
| 1216 | /* ^^^ note that it is intended that both ctrl-enter and enter |
| 1217 | work for single-line input mode. */ |
| 1218 |