mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #11601, dont trigger edit if chat input has text
pressing escape will cancel edit
This commit is contained in:
@@ -235,15 +235,14 @@ define('forum/chats', [
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
mousetrap.bind('up', function (e) {
|
mousetrap.bind('up', function (e) {
|
||||||
if (e.target === components.get('chat/input').get(0)) {
|
const inputEl = components.get('chat/input');
|
||||||
|
if (e.target === inputEl.get(0) && !inputEl.val()) {
|
||||||
// Retrieve message id from messages list
|
// Retrieve message id from messages list
|
||||||
const message = components.get('chat/messages').find('.chat-message[data-self="1"]').last();
|
const message = components.get('chat/messages').find('.chat-message[data-self="1"]').last();
|
||||||
if (!message.length) {
|
if (!message.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const lastMid = message.attr('data-mid');
|
const lastMid = message.attr('data-mid');
|
||||||
const inputEl = components.get('chat/input');
|
|
||||||
|
|
||||||
messages.prepEdit(inputEl, lastMid, ajaxify.data.roomId);
|
messages.prepEdit(inputEl, lastMid, ajaxify.data.roomId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -176,6 +176,11 @@ define('forum/chats/messages', [
|
|||||||
autoCompleteEl.destroy();
|
autoCompleteEl.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
textarea.on('keyup', (e) => {
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
finishEdit();
|
||||||
|
}
|
||||||
|
});
|
||||||
editEl.find('[data-action="cancel"]').on('click', finishEdit);
|
editEl.find('[data-action="cancel"]').on('click', finishEdit);
|
||||||
|
|
||||||
editEl.find('[data-action="save"]').on('click', function () {
|
editEl.find('[data-action="save"]').on('click', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user