The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix: prevent saving tiny scroll positions in restoration hook (#13554)
nitin75214c3e613a
diff --git a/packages/twenty-front/src/modules/ui/utilities/scroll/constants/ScrollRestorationTopThreshold.ts b/packages/twenty-front/src/modules/ui/utilities/scroll/constants/ScrollRestorationTopThreshold.tsnew file mode 100644index 00000000000..679b88d5fb4--- /dev/null+++ b/packages/twenty-front/src/modules/ui/utilities/scroll/constants/ScrollRestorationTopThreshold.ts@@ -0,0 +1 @@+export const SCROLL_RESTORATION_TOP_THRESHOLD_PX = 3;diff --git a/packages/twenty-front/src/modules/ui/utilities/scroll/hooks/useScrollRestoration.ts b/packages/twenty-front/src/modules/ui/utilities/scroll/hooks/useScrollRestoration.tsindex 9eceed5c3f5..db9ad13a3e3 100644--- a/packages/twenty-front/src/modules/ui/utilities/scroll/hooks/useScrollRestoration.ts+++ b/packages/twenty-front/src/modules/ui/utilities/scroll/hooks/useScrollRestoration.ts@@ -1,3 +1,4 @@+import { SCROLL_RESTORATION_TOP_THRESHOLD_PX } from '@/ui/utilities/scroll/constants/ScrollRestorationTopThreshold';import { scrollWrapperScrollTopComponentState } from '@/ui/utilities/scroll/states/scrollWrapperScrollTopComponentState';import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';import { useCallback, useEffect, useState } from 'react';@@ -43,9 +44,14 @@ export const useScrollRestoration = (componentInstanceId: string) => {);useEffect(() => {- if (scrollTop > 0 && !isRestoring) {- sessionStorage.setItem(storageKey, scrollTop.toString());+ if (isRestoring) return;++ if (scrollTop <= SCROLL_RESTORATION_TOP_THRESHOLD_PX) {+ sessionStorage.removeItem(storageKey);+ return;}++ sessionStorage.setItem(storageKey, scrollTop.toString());}, [scrollTop, storageKey, isRestoring]);useEffect(() => {