Skip to content

Commit cb5237d

Browse files
fix: optimize event listener cleanup and scope wheel event to sidebar
- Make event listener cleanup conditional based on platform - Add container.contains check to wheel event to prevent affecting whole app - Fixes code review feedback from Greptile Co-authored-by: Anthony <AnthonyRonning@users.noreply.github.com>
1 parent 437370c commit cb5237d

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎frontend/src/components/ChatHistoryList.tsx‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ export function ChatHistoryList({
290290
consthandleWheel=(e: WheelEvent)=>{
291291
if(!isDesktopPlatform||isPullRefreshing)return;
292292

293+
// Only handle if the event target is within our container
294+
if(!container.contains(e.targetasNode))return;
295+
293296
// Check if we're at the top and trying to scroll up
294297
if(container.scrollTop===0&&e.deltaY<0){
295298
// Prevent default to avoid browser overscroll bounce
@@ -318,10 +321,14 @@ export function ChatHistoryList({
318321
container.removeEventListener("touchstart",handleTouchStart);
319322
container.removeEventListener("touchmove",handleTouchMove);
320323
container.removeEventListener("touchend",handleTouchEnd);
321-
container.removeEventListener("wheel",handleWheel);
322-
container.removeEventListener("mousedown",handleMouseDown);
323-
window.removeEventListener("mousemove",handleMouseMove);
324-
window.removeEventListener("mouseup",handleMouseUp);
324+
325+
if(isDesktopPlatform){
326+
container.removeEventListener("wheel",handleWheel);
327+
}else{
328+
container.removeEventListener("mousedown",handleMouseDown);
329+
window.removeEventListener("mousemove",handleMouseMove);
330+
window.removeEventListener("mouseup",handleMouseUp);
331+
}
325332
};
326333
},[containerRef,isPullRefreshing,handleRefresh]);
327334

0 commit comments

Comments
 (0)