[FIX] mail: chatwindow scroll to the last message when posting
Before this commit, when a user posted a message from a chatwindow, the scroll did not move to the last message. task-2314409 closes odoo/odoo#57183 X-original-commit: 8e4f133890b08e7e9a909abbc97b89bb5409119a Signed-off-by: Sébastien Theys (seb) <seb@odoo.com> Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -1617,6 +1617,44 @@ QUnit.test('chat window with a thread: keep scroll position in message list on f
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('chat window should scroll to the newly posted message just after posting it', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
this.data['mail.channel'].records.push({
|
||||
id: 20,
|
||||
is_minimized: true,
|
||||
state: 'open',
|
||||
});
|
||||
for (let i = 0; i < 10; i++) {
|
||||
this.data['mail.message'].records.push({
|
||||
channel_ids: [20],
|
||||
model: 'mail.channel',
|
||||
res_id: 20,
|
||||
});
|
||||
}
|
||||
await this.start();
|
||||
|
||||
// Set content of the composer of the chat window
|
||||
await afterNextRender(() => {
|
||||
document.querySelector('.o_ComposerTextInput_textarea').focus();
|
||||
document.execCommand('insertText', false, 'WOLOLO');
|
||||
});
|
||||
// Send a new message in the chatwindow to trigger the scroll
|
||||
await afterNextRender(() =>
|
||||
triggerEvent(
|
||||
document.querySelector('.o_ChatWindow .o_ComposerTextInput_textarea'),
|
||||
'keydown',
|
||||
{ key: 'Enter' },
|
||||
)
|
||||
);
|
||||
const messageList = document.querySelector('.o_MessageList');
|
||||
assert.strictEqual(
|
||||
messageList.scrollHeight - messageList.scrollTop,
|
||||
messageList.clientHeight,
|
||||
"chat window should scroll to the newly posted message just after posting it"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('[technical] chat window: composer state conservation on toggle home menu when folded', async function (assert) {
|
||||
// technical as show/hide home menu simulation are involved and home menu implementation
|
||||
// have side-effects on DOM that may make chat window components not work
|
||||
|
||||
@@ -182,7 +182,7 @@ function factory(dependencies) {
|
||||
thread.loadNewMessages();
|
||||
}
|
||||
for (const threadView of this.thread.threadViews) {
|
||||
threadView.addComponentHint('current-partner-just-posted-message', messageId);
|
||||
threadView.addComponentHint('current-partner-just-posted-message', { messageId });
|
||||
}
|
||||
this._reset();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user