@true-engineering/true-react-common-ui-kit 3.0.0-alpha.13 → 3.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode, RefObject, useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import { addDataTestId, isNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
3
|
+
import { addDataTestId, isEmpty, isNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
4
4
|
import { addDataAttributes } from '../../helpers';
|
|
5
5
|
import { useTweakStyles } from '../../hooks';
|
|
6
6
|
import { ICommonProps } from '../../types';
|
|
@@ -105,15 +105,22 @@ export function FlexibleTable<Values extends Record<string, any>>({
|
|
|
105
105
|
|
|
106
106
|
useEffect(() => {
|
|
107
107
|
const scrollContainer = ref.current;
|
|
108
|
-
if (scrollContainer
|
|
108
|
+
if (isEmpty(scrollContainer) || !isHorizontallyScrollable || !isFirstColumnSticky) {
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
const scrollHandler = (
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
|
|
112
|
+
const scrollHandler = () => setIsHorizontallyScrolled(scrollContainer.scrollLeft > 0);
|
|
113
|
+
const resizeHandler = () => setHasScrollBar(hasHorizontalScrollBar(scrollContainer));
|
|
114
|
+
|
|
115
|
+
resizeHandler();
|
|
116
|
+
|
|
115
117
|
scrollContainer.addEventListener('scroll', scrollHandler);
|
|
116
|
-
|
|
118
|
+
document.addEventListener('resize', resizeHandler);
|
|
119
|
+
|
|
120
|
+
return () => {
|
|
121
|
+
scrollContainer.removeEventListener('scroll', scrollHandler);
|
|
122
|
+
document.removeEventListener('resize', resizeHandler);
|
|
123
|
+
};
|
|
117
124
|
}, [ref]);
|
|
118
125
|
|
|
119
126
|
return (
|