mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:16:08 +08:00
FIX: messages list shouldn't scroll on new message (#26438)
The expected behavior when receiving a message is the following: - if user is at the bottom of the screen, scroll and append message - if user is not at the bottom of the screen, don't scroll, show arrow and don't append message
This commit is contained in:
parent
07605e52c2
commit
453bf3acb3
|
@ -74,7 +74,7 @@ export default class ChatChannel extends Component {
|
|||
@tracked showChatQuoteSuccess = false;
|
||||
@tracked includeHeader = true;
|
||||
@tracked needsArrow = false;
|
||||
@tracked atBottom = false;
|
||||
@tracked atBottom = true;
|
||||
@tracked uploadDropZone;
|
||||
@tracked isScrolling = false;
|
||||
|
||||
|
@ -173,6 +173,12 @@ export default class ChatChannel extends Component {
|
|||
|
||||
@bind
|
||||
onNewMessage(message) {
|
||||
if (!this.atBottom) {
|
||||
this.needsArrow = true;
|
||||
this.messagesLoader.canLoadMoreFuture = true;
|
||||
return;
|
||||
}
|
||||
|
||||
stackingContextFix(this.scrollable, () => {
|
||||
this.messagesManager.addMessages([message]);
|
||||
});
|
||||
|
|
|
@ -53,7 +53,7 @@ export default class ChatThread extends Component {
|
|||
@service router;
|
||||
@service siteSettings;
|
||||
|
||||
@tracked isAtBottom = true;
|
||||
@tracked atBottom = true;
|
||||
@tracked isScrolling = false;
|
||||
@tracked needsArrow = false;
|
||||
@tracked uploadDropZone;
|
||||
|
@ -316,7 +316,15 @@ export default class ChatThread extends Component {
|
|||
|
||||
@bind
|
||||
onNewMessage(message) {
|
||||
this.messagesManager.addMessages([message]);
|
||||
if (!this.atBottom) {
|
||||
this.needsArrow = true;
|
||||
this.messagesLoader.canLoadMoreFuture = true;
|
||||
return;
|
||||
}
|
||||
|
||||
stackingContextFix(this.scrollable, () => {
|
||||
this.messagesManager.addMessages([message]);
|
||||
});
|
||||
}
|
||||
|
||||
@bind
|
||||
|
|
|
@ -164,12 +164,12 @@ RSpec.describe "Chat channel", type: :system do
|
|||
50.times { Fabricate(:chat_message, chat_channel: channel_1) }
|
||||
end
|
||||
|
||||
xit "doesn’t scroll the pane" do
|
||||
it "doesn’t append the message when not at bottom" do
|
||||
visit("/chat/c/-/#{channel_1.id}/#{message_1.id}")
|
||||
|
||||
new_message = Fabricate(:chat_message, chat_channel: channel_1)
|
||||
new_message = Fabricate(:chat_message, chat_channel: channel_1, use_service: true)
|
||||
|
||||
expect(page).to have_no_content(new_message.message)
|
||||
expect(channel_page.messages).to have_no_message(id: new_message.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user