@true-engineering/true-react-common-ui-kit 3.0.0-alpha.13 → 3.0.0-alpha.15

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
  {
2
2
  "name": "@true-engineering/true-react-common-ui-kit",
3
- "version": "3.0.0-alpha.13",
3
+ "version": "3.0.0-alpha.15",
4
4
  "description": "True Engineering React UI Kit with theming support",
5
5
  "author": "True Engineering (https://trueengineering.ru)",
6
6
  "keywords": [
@@ -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,27 @@ export function FlexibleTable<Values extends Record<string, any>>({
105
105
 
106
106
  useEffect(() => {
107
107
  const scrollContainer = ref.current;
108
- if (scrollContainer === null || !isHorizontallyScrollable || !isFirstColumnSticky) {
108
+ if (isEmpty(scrollContainer) || !isHorizontallyScrollable || !isFirstColumnSticky) {
109
109
  return;
110
110
  }
111
- setHasScrollBar(hasHorizontalScrollBar(scrollContainer));
112
- const scrollHandler = (e: Event) => {
113
- setIsHorizontallyScrolled((e.target as HTMLDivElement).scrollLeft > 0);
111
+
112
+ const scrollHandler = () => {
113
+ setIsHorizontallyScrolled(scrollContainer.scrollLeft > 0);
114
+ };
115
+
116
+ const resizeHandler = () => {
117
+ setHasScrollBar(hasHorizontalScrollBar(scrollContainer));
114
118
  };
119
+
120
+ resizeHandler();
121
+
115
122
  scrollContainer.addEventListener('scroll', scrollHandler);
116
- return () => scrollContainer.removeEventListener('scroll', scrollHandler);
123
+ window.addEventListener('resize', resizeHandler);
124
+
125
+ return () => {
126
+ scrollContainer.removeEventListener('scroll', scrollHandler);
127
+ window.removeEventListener('resize', resizeHandler);
128
+ };
117
129
  }, [ref]);
118
130
 
119
131
  return (