🐛(frontend) remove scroll listener table content

During a useEffect cleaning, the selector was
not the correct one. The debounce was not being
removed correctly neither.
This commit is contained in:
Anthony LC
2025-03-10 09:29:33 +01:00
committed by Anthony LC
parent 197ba47f73
commit fdc49dc002
2 changed files with 21 additions and 5 deletions

View File

@@ -8,6 +8,11 @@ and this project adheres to
## [Unreleased] ## [Unreleased]
## Fixed
- 🐛(frontend) remove scroll listener table content #688
- 🔒️(back) restrict access to favorite_list endpoint #690
## [2.4.0] - 2025-03-06 ## [2.4.0] - 2025-03-06
## Added ## Added
@@ -21,7 +26,7 @@ and this project adheres to
## Fixed ## Fixed
- 🐛(frontend) fix collaboration error #684 - 🐛(frontend) fix collaboration error #684
- 🔒️(back) restrict access to favorite_list endpoint #690
## [2.3.0] - 2025-03-03 ## [2.3.0] - 2025-03-03

View File

@@ -48,16 +48,27 @@ export const TableContent = () => {
} }
}; };
document.getElementById(MAIN_LAYOUT_ID)?.addEventListener('scroll', () => { let timeout: NodeJS.Timeout;
setTimeout(() => { const scrollFn = () => {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(() => {
handleScroll(); handleScroll();
}, 300); }, 300);
}); };
document
.getElementById(MAIN_LAYOUT_ID)
?.addEventListener('scroll', scrollFn);
handleScroll(); handleScroll();
return () => { return () => {
window.removeEventListener('scroll', handleScroll); document
.getElementById(MAIN_LAYOUT_ID)
?.removeEventListener('scroll', scrollFn);
}; };
}, [headings, setHeadingIdHighlight]); }, [headings, setHeadingIdHighlight]);