Skip to content

Commit

Permalink
feat: remove timeout for scrolling to filtered conversation (wireapp#…
Browse files Browse the repository at this point in the history
  • Loading branch information
przemvs authored Oct 16, 2024
1 parent 9ba24d0 commit c0b7de4
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/script/page/LeftSidebar/panels/Conversations/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,21 @@ export const conversationSearchFilter = (filter: string) => (conversation: Conve
};

export const scrollToConversation = (conversationId: string) => {
const timeout = setTimeout(() => {
const element = document.querySelector<HTMLElement>(`.conversation-list-cell[data-uie-uid="${conversationId}"]`);
const element = document.querySelector<HTMLElement>(`.conversation-list-cell[data-uie-uid="${conversationId}"]`);

if (!element) {
return;
}

const rect = element.getBoundingClientRect();
if (!element) {
return;
}

const isVisible =
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth);
const rect = element.getBoundingClientRect();

if (!isVisible) {
element.scrollIntoView({behavior: 'instant', block: 'center', inline: 'nearest'});
}
const isVisible =
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth);

clearTimeout(timeout);
}, 1);
if (!isVisible) {
element.scrollIntoView({behavior: 'instant', block: 'center', inline: 'nearest'});
}
};

0 comments on commit c0b7de4

Please sign in to comment.