mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36: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) {
|
||||
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
|
||||
const message = components.get('chat/messages').find('.chat-message[data-self="1"]').last();
|
||||
if (!message.length) {
|
||||
return;
|
||||
}
|
||||
const lastMid = message.attr('data-mid');
|
||||
const inputEl = components.get('chat/input');
|
||||
|
||||
messages.prepEdit(inputEl, lastMid, ajaxify.data.roomId);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -176,6 +176,11 @@ define('forum/chats/messages', [
|
||||
autoCompleteEl.destroy();
|
||||
}
|
||||
}
|
||||
textarea.on('keyup', (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
finishEdit();
|
||||
}
|
||||
});
|
||||
editEl.find('[data-action="cancel"]').on('click', finishEdit);
|
||||
|
||||
editEl.find('[data-action="save"]').on('click', function () {
|
||||
|
||||
Reference in New Issue
Block a user