PluginProbe
MxChat – AI Chatbot & Content Generation for WordPress / 3.2.23
MxChat – AI Chatbot & Content Generation for WordPress v3.2.23
3.2.25 3.2.24 3.2.23 3.2.22 3.2.21 3.2.20 3.2.19 3.2.18 3.2.17 3.2.16 3.2.15 3.2.14 3.2.12 3.2.13 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 3.2.6 3.2.5 3.2.4 3.2.3 3.2.2 3.2.1 All 156 releases
← All changes | js/chat-script.js +17 -12 3.2.22 → 3.2.23 View file →
@@ -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).