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

View File

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