| @@ -847,9 +847,12 @@ | ||
| 847 | 847 | if (typeof customMxChatFilter === 'function') { |
| 848 | 848 | message = customMxChatFilter(message, "prompt"); |
| 849 | 849 | } |
| 850 | 850 | |
| 851 | - if (message) { | |
| 851 | + // Whitespace-only is empty: nothing is sent and nothing is disabled. When | |
| 852 | + // there IS a message the original string (spaces and all) is what goes out, | |
| 853 | + // so the transcript is unchanged (plan b67fd5). | |
| 854 | + if (message && String(message).trim() !== '') { | |
| 852 | 855 | // Don't disable input in live agent mode - let users chat freely |
| 853 | 856 | var modeIndicator = getElementDOM(botId, 'chat-mode-indicator'); |
| 854 | 857 | var isAgentMode = modeIndicator && modeIndicator.textContent === 'Live Agent'; |
| 855 | 858 | if (!isAgentMode) { |
| @@ -893,8 +896,14 @@ | ||
| 893 | 896 | if (typeof customMxChatFilter === 'function') { |
| 894 | 897 | message = customMxChatFilter(message, "prompt"); |
| 895 | 898 | } |
| 896 | 899 | |
| 900 | + // Nothing to send means nothing to disable (plan b67fd5): a caller handing | |
| 901 | + // over an empty string must not lock the box the way Enter-on-empty did. | |
| 902 | + if (!message || String(message).trim() === '') { | |
| 903 | + return; | |
| 904 | + } | |
| 905 | + | |
| 897 | 906 | // Don't disable input in live agent mode - let users chat freely |
| 898 | 907 | var modeIndicator = getElementDOM(botId, 'chat-mode-indicator'); |
| 899 | 908 | var isAgentMode = modeIndicator && modeIndicator.textContent === 'Live Agent'; |
| 900 | 909 | if (!isAgentMode) { |
| @@ -1753,25 +1762,21 @@ | ||
| 1753 | 1762 | if (this.__mxchatStopJustShown) return; |
| 1754 | 1763 | mxchatStopStreaming(botId); |
| 1755 | 1764 | return; |
| 1756 | 1765 | } |
| 1757 | - var modeIndicator = getElementDOM(botId, 'chat-mode-indicator'); | |
| 1758 | - if (!(modeIndicator && modeIndicator.textContent === 'Live Agent')) { | |
| 1759 | - disableChatInput(botId); | |
| 1760 | - } | |
| 1766 | + // sendMessage() owns the disable - see the Enter handler below (plan b67fd5). | |
| 1761 | 1767 | sendMessage(botId); |
| 1762 | 1768 | }); |
| 1763 | 1769 | |
| 1764 | -// Override enter key handler (using event delegation) | |
| 1770 | +// Enter sends, Shift+Enter inserts a newline (using event delegation). | |
| 1771 | +// sendMessage() owns the disable: it greys the box only when a real message is | |
| 1772 | +// about to go out. Disabling here first left the widget locked for good after | |
| 1773 | +// Enter on an empty box - the send returned early and no reply path ever | |
| 1774 | +// re-enabled it (plan b67fd5). | |
| 1765 | 1775 | $(document).on('keypress', '.chat-input', function(e) { |
| 1766 | 1776 | if (e.which == 13 && !e.shiftKey) { |
| 1767 | 1777 | e.preventDefault(); |
| 1768 | - var botId = getBotIdFromElement(this); | |
| 1769 | - var modeIndicator = getElementDOM(botId, 'chat-mode-indicator'); | |
| 1770 | - if (!(modeIndicator && modeIndicator.textContent === 'Live Agent')) { | |
| 1771 | - disableChatInput(botId); | |
| 1772 | - } | |
| 1773 | - sendMessage(botId); | |
| 1778 | + sendMessage(getBotIdFromElement(this)); | |
| 1774 | 1779 | } |
| 1775 | 1780 | }); |
| 1776 | 1781 | |
| 1777 | 1782 | // Chat input character counter + soft limit feedback (plan 7091a2). |