Skip to content

Commit 09f02ee

Browse files
committed
fix hydration error
1 parent 619d18e commit 09f02ee

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

packages/main/src/components/AnalyticalTable/hooks/useSyncScroll.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ export function useSyncScroll(
1010
const [isMounted, setIsMounted] = useState(false);
1111

1212
useEffect(() => {
13-
const content = refContent.current;
14-
const scrollbar = refScrollbar.current;
15-
1613
if (disabled) {
1714
return;
1815
}
1916

17+
const content = refContent.current;
18+
const scrollbar = refScrollbar.current;
19+
2020
if (!content || !scrollbar || !isMounted) {
2121
setIsMounted(true);
2222
return;
@@ -46,5 +46,5 @@ export function useSyncScroll(
4646
content.removeEventListener('scroll', onScrollContent);
4747
scrollbar.removeEventListener('scroll', onScrollScrollbar);
4848
};
49-
}, [isMounted, refContent, refScrollbar]);
49+
}, [isMounted, refContent, refScrollbar, disabled]);
5050
}

packages/main/src/components/AnalyticalTable/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
useStylesheet,
1111
useSyncRef,
1212
} from '@ui5/webcomponents-react-base';
13-
import { isFirefox as isFireFoxFn } from '@ui5/webcomponents-react-base/Device';
13+
import { isFirefox as isFirefoxFn } from '@ui5/webcomponents-react-base/Device';
1414
import { clsx } from 'clsx';
1515
import type { CSSProperties, MutableRefObject } from 'react';
1616
import { forwardRef, useCallback, useEffect, useId, useMemo, useRef } from 'react';
@@ -100,8 +100,6 @@ import {
100100
} from './util/index.js';
101101
import { VerticalResizer } from './VerticalResizer.js';
102102

103-
const isFirefox = isFireFoxFn();
104-
105103
// When a sorted column is removed from the visible columns array (e.g. when "popped-in"), it doesn't clean up the sorted columns leading to an undefined `sortType`.
106104
const sortTypesFallback = {
107105
undefined: () => undefined,
@@ -193,6 +191,7 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
193191
useStylesheet(styleData, AnalyticalTable.displayName);
194192
const isInitialized = useRef(false);
195193
const fontsReady = useFontsReady();
194+
const isFirefox = useMemo(() => isFirefoxFn(), []);
196195

197196
const alwaysShowSubComponent =
198197
subComponentsBehavior === AnalyticalTableSubComponentsBehavior.Visible ||

packages/main/src/components/AnalyticalTable/scrollbars/VerticalScrollbar.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { isChrome as isChromeFn } from '@ui5/webcomponents-react-base/Device';
22
import { useSyncRef } from '@ui5/webcomponents-react-base/internal/hooks';
33
import { clsx } from 'clsx';
44
import type { MutableRefObject } from 'react';
5-
import { forwardRef, useEffect, useRef } from 'react';
5+
import { forwardRef, useEffect, useMemo, useRef } from 'react';
66
import { FlexBoxDirection } from '../../../enums/FlexBoxDirection.js';
77
import { FlexBox } from '../../FlexBox/index.js';
88
import type { ClassNames } from '../types/index.js';
@@ -15,14 +15,13 @@ interface VerticalScrollbarProps {
1515
classNames: ClassNames;
1616
}
1717

18-
const isChrome = isChromeFn();
19-
2018
export const VerticalScrollbar = forwardRef<HTMLDivElement, VerticalScrollbarProps>((props, ref) => {
2119
const { internalRowHeight, tableRef, tableBodyHeight, scrollContainerRef, classNames } = props;
2220
const hasHorizontalScrollbar = tableRef?.current?.offsetWidth !== tableRef?.current?.scrollWidth;
2321
const horizontalScrollbarSectionStyles = clsx(hasHorizontalScrollbar && classNames.bottomSection);
2422
const [componentRef, scrollbarRef] = useSyncRef<HTMLDivElement>(ref);
2523
const contentRef = useRef<HTMLDivElement>(null);
24+
const isChrome = useMemo(() => isChromeFn(), []);
2625

2726
// Force style recalculation to fix Chrome scrollbar-color bug (track height not updating correctly)
2827
useEffect(() => {
@@ -43,7 +42,7 @@ export const VerticalScrollbar = forwardRef<HTMLDivElement, VerticalScrollbarPro
4342

4443
requestAnimationFrame(forceScrollbarUpdate);
4544
}
46-
}, [tableBodyHeight, scrollContainerRef.current?.scrollHeight, scrollbarRef]);
45+
}, [tableBodyHeight, scrollContainerRef.current?.scrollHeight, scrollbarRef, isChrome]);
4746

4847
return (
4948
<FlexBox

0 commit comments

Comments
 (0)