ehscan-react-table 0.0.21 → 0.0.23

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.
@@ -32,17 +32,13 @@ export const Table = ({ columns, rows, sortOrder, setSortOrder, cellComponents,
32
32
  const calculateHeight = () => {
33
33
  if (headerRef.current) {
34
34
  const { bottom } = headerRef.current.getBoundingClientRect();
35
- console.log(bottom);
36
- setWrapperBottom(bottom);
35
+ setWrapperBottom(bottom - 20);
37
36
  }
38
37
  };
39
38
  calculateHeight();
40
39
  window.addEventListener("resize", calculateHeight);
41
40
  return () => window.removeEventListener("resize", calculateHeight);
42
41
  }, []);
43
- useEffect(() => {
44
- console.log(wrapperBottom);
45
- }, [wrapperBottom]);
46
42
  const checkHead = (entry) => {
47
43
  if (entry === undefined)
48
44
  return;
@@ -110,22 +106,23 @@ export const Table = ({ columns, rows, sortOrder, setSortOrder, cellComponents,
110
106
  : _jsx("div", { onClick: () => setOpenCol(tag), children: colTitle }) })] }) }));
111
107
  };
112
108
  useEffect(() => {
113
- const entries = Object.entries(colRefs.current)
114
- .filter(([, el]) => el !== null);
115
- if (entries.length === 0)
116
- return;
117
- const observer = new ResizeObserver((entries) => {
118
- entries.forEach((entry) => {
119
- const tag = Object.keys(colRefs.current)
120
- .find(k => colRefs.current[k] === entry.target);
121
- if (tag) {
122
- const width = entry.contentRect.width;
123
- console.log(`Column "${tag}" resized to`, width);
124
- }
109
+ const timeout = setTimeout(() => {
110
+ const observer = new ResizeObserver((entries) => {
111
+ entries.forEach((entry) => {
112
+ const tag = Object.keys(colRefs.current).find(k => colRefs.current[k] === entry.target);
113
+ if (tag) {
114
+ const width = entry.contentRect.width;
115
+ console.log(`Column "${tag}" resized to:`, width);
116
+ }
117
+ });
125
118
  });
126
- });
127
- entries.forEach(([, el]) => observer.observe(el));
128
- return () => observer.disconnect();
119
+ Object.values(colRefs.current).forEach((el) => {
120
+ if (el)
121
+ observer.observe(el);
122
+ });
123
+ return () => observer.disconnect();
124
+ }, 50); // 50ms is usually enough
125
+ return () => clearTimeout(timeout);
129
126
  }, []);
130
127
  const HeadCols = () => {
131
128
  return (_jsxs(_Fragment, { children: [columns.map((col, i) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ehscan-react-table",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "components",
5
5
  "main": "dist/Components.js",
6
6
  "types": "dist/Components.d.ts",