Skip to content

Commit 1189101

Browse files
authored
Merge pull request #387 from GetStream/jump-to-latest-button-problem
fix: Jump to latest button appears if changed to an empty channel
2 parents 8dd6e28 + 4e2fd40 commit 1189101

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

projects/stream-chat-angular/src/lib/message-list/message-list.component.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,18 @@ describe('MessageListComponent', () => {
690690
expect(queryTypingUsers()?.textContent).toContain('jack, John');
691691
});
692692

693+
it(`shouldn't display scroll to latest button if there is no scrollbar`, () => {
694+
const scrollContainer = queryScrollContainer();
695+
696+
scrollContainer!.style.maxHeight = `${scrollContainer!.scrollHeight}px`;
697+
fixture.detectChanges();
698+
699+
component.scrolled();
700+
fixture.detectChanges();
701+
702+
expect(queryScrollToLatestButton()).toBeNull();
703+
});
704+
693705
describe('thread mode', () => {
694706
beforeEach(() => {
695707
component.mode = 'thread';

projects/stream-chat-angular/src/lib/message-list/message-list.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ export class MessageListComponent
250250
}
251251

252252
scrolled() {
253+
if (
254+
this.scrollContainer.nativeElement.scrollHeight ===
255+
this.scrollContainer.nativeElement.clientHeight
256+
) {
257+
return;
258+
}
253259
const scrollPosition = this.getScrollPosition();
254260

255261
this.isUserScrolled =

0 commit comments

Comments
 (0)