@atlaskit/editor-plugin-table 7.5.5 → 7.5.6

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/event-handlers.js +25 -9
  3. package/dist/cjs/nodeviews/OverflowShadowsObserver.js +24 -15
  4. package/dist/cjs/nodeviews/TableCell.js +5 -30
  5. package/dist/cjs/nodeviews/TableComponent.js +74 -24
  6. package/dist/cjs/nodeviews/TableContainer.js +19 -17
  7. package/dist/cjs/nodeviews/TableResizer.js +1 -1
  8. package/dist/cjs/plugin.js +2 -3
  9. package/dist/cjs/pm-plugins/main.js +3 -18
  10. package/dist/cjs/ui/TableFloatingColumnControls/index.js +8 -48
  11. package/dist/cjs/ui/TableFloatingControls/index.js +113 -223
  12. package/dist/cjs/utils/column-controls.js +5 -5
  13. package/dist/cjs/utils/dom.js +13 -15
  14. package/dist/es2019/event-handlers.js +25 -9
  15. package/dist/es2019/nodeviews/OverflowShadowsObserver.js +24 -15
  16. package/dist/es2019/nodeviews/TableCell.js +1 -24
  17. package/dist/es2019/nodeviews/TableComponent.js +63 -27
  18. package/dist/es2019/nodeviews/TableContainer.js +16 -18
  19. package/dist/es2019/nodeviews/TableResizer.js +1 -1
  20. package/dist/es2019/plugin.js +2 -3
  21. package/dist/es2019/pm-plugins/main.js +3 -18
  22. package/dist/es2019/ui/TableFloatingColumnControls/index.js +5 -27
  23. package/dist/es2019/ui/TableFloatingControls/index.js +119 -193
  24. package/dist/es2019/utils/column-controls.js +6 -6
  25. package/dist/es2019/utils/dom.js +13 -15
  26. package/dist/esm/event-handlers.js +25 -9
  27. package/dist/esm/nodeviews/OverflowShadowsObserver.js +24 -15
  28. package/dist/esm/nodeviews/TableCell.js +5 -30
  29. package/dist/esm/nodeviews/TableComponent.js +74 -24
  30. package/dist/esm/nodeviews/TableContainer.js +20 -18
  31. package/dist/esm/nodeviews/TableResizer.js +1 -1
  32. package/dist/esm/plugin.js +2 -3
  33. package/dist/esm/pm-plugins/main.js +3 -18
  34. package/dist/esm/ui/TableFloatingColumnControls/index.js +8 -48
  35. package/dist/esm/ui/TableFloatingControls/index.js +113 -224
  36. package/dist/esm/utils/column-controls.js +6 -6
  37. package/dist/esm/utils/dom.js +13 -15
  38. package/dist/types/event-handlers.d.ts +3 -4
  39. package/dist/types/nodeviews/OverflowShadowsObserver.d.ts +3 -1
  40. package/dist/types/nodeviews/TableCell.d.ts +1 -5
  41. package/dist/types/nodeviews/TableComponent.d.ts +4 -0
  42. package/dist/types/nodeviews/TableContainer.d.ts +4 -2
  43. package/dist/types/types.d.ts +0 -3
  44. package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -1
  45. package/dist/types/ui/TableFloatingControls/index.d.ts +5 -22
  46. package/dist/types/utils/dom.d.ts +10 -2
  47. package/dist/types-ts4.5/event-handlers.d.ts +3 -4
  48. package/dist/types-ts4.5/nodeviews/OverflowShadowsObserver.d.ts +3 -1
  49. package/dist/types-ts4.5/nodeviews/TableCell.d.ts +1 -5
  50. package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +4 -0
  51. package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +4 -2
  52. package/dist/types-ts4.5/types.d.ts +0 -3
  53. package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -1
  54. package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +5 -22
  55. package/dist/types-ts4.5/utils/dom.d.ts +10 -2
  56. package/package.json +3 -4
  57. package/src/event-handlers.ts +105 -103
  58. package/src/nodeviews/OverflowShadowsObserver.ts +32 -21
  59. package/src/nodeviews/TableCell.ts +0 -26
  60. package/src/nodeviews/TableComponent.tsx +76 -32
  61. package/src/nodeviews/TableContainer.tsx +19 -25
  62. package/src/nodeviews/TableResizer.tsx +1 -4
  63. package/src/plugin.tsx +5 -4
  64. package/src/pm-plugins/main.ts +3 -22
  65. package/src/types.ts +0 -4
  66. package/src/ui/TableFloatingColumnControls/index.tsx +5 -29
  67. package/src/ui/TableFloatingControls/index.tsx +155 -241
  68. package/src/utils/column-controls.ts +5 -6
  69. package/src/utils/dom.ts +12 -19
@@ -84,6 +84,12 @@ const isIE11 = browser.ie_version === 11;
84
84
  // To make sure we capture the last update, we use setTimeout.
85
85
  const initialOverflowCaptureTimeroutDelay = 300;
86
86
 
87
+ // This is a hard switch for controlling whether the overflow analytics should be dispatched. There has been 6months of data
88
+ // already collected which we could use but have not. This has been disabled rather then removed entirely in the event that
89
+ // the current collected data becomes stale and we want to start collecting fresh data again in future.
90
+ // PLEASE NOTE: that the current way this alaytics has been configured WILL cause reflows to occur. This is why the has been disabled.
91
+ const isOverflowAnalyticsEnabled = false;
92
+
87
93
  export interface ComponentProps {
88
94
  view: EditorView;
89
95
  getNode: () => PmNode;
@@ -114,6 +120,8 @@ interface TableState {
114
120
  stickyHeader?: RowStickyState;
115
121
  [ShadowEvent.SHOW_BEFORE_SHADOW]: boolean;
116
122
  [ShadowEvent.SHOW_AFTER_SHADOW]: boolean;
123
+ tableWrapperWidth?: number;
124
+ tableWrapperHeight?: number;
117
125
  }
118
126
 
119
127
  class TableComponent extends React.Component<ComponentProps, TableState> {
@@ -124,6 +132,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
124
132
  parentWidth: undefined,
125
133
  [ShadowEvent.SHOW_BEFORE_SHADOW]: false,
126
134
  [ShadowEvent.SHOW_AFTER_SHADOW]: false,
135
+ tableWrapperWidth: undefined,
136
+ tableWrapperHeight: undefined,
127
137
  };
128
138
 
129
139
  private wrapper?: HTMLDivElement | null;
@@ -136,6 +146,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
136
146
 
137
147
  private isInitialOverflowSent: boolean;
138
148
  private initialOverflowCaptureTimerId?: ReturnType<typeof setTimeout>;
149
+ private resizeObserver?: ResizeObserver;
139
150
 
140
151
  private dragAndDropCleanupFn?: CleanupFn;
141
152
 
@@ -158,6 +169,21 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
158
169
  },
159
170
  );
160
171
 
172
+ this.resizeObserver = new ResizeObserver((entries) => {
173
+ for (let entry of entries) {
174
+ this.setState((prev) => {
175
+ return prev?.tableWrapperWidth === entry.contentRect?.width &&
176
+ prev?.tableWrapperHeight === entry.contentRect?.height
177
+ ? prev
178
+ : {
179
+ ...prev,
180
+ tableWrapperWidth: entry.contentRect.width,
181
+ tableWrapperHeight: entry.contentRect.height,
182
+ };
183
+ });
184
+ }
185
+ });
186
+
161
187
  // Disable inline table editing and resizing controls in Firefox
162
188
  // https://github.com/ProseMirror/prosemirror/issues/432
163
189
  if ('execCommand' in document) {
@@ -231,11 +257,13 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
231
257
 
232
258
  eventDispatcher.on((stickyHeadersPluginKey as any).key, this.onStickyState);
233
259
 
234
- const initialIsOveflowing =
235
- this.state[ShadowEvent.SHOW_BEFORE_SHADOW] ||
236
- this.state[ShadowEvent.SHOW_AFTER_SHADOW];
260
+ if (isOverflowAnalyticsEnabled) {
261
+ const initialIsOveflowing =
262
+ this.state[ShadowEvent.SHOW_BEFORE_SHADOW] ||
263
+ this.state[ShadowEvent.SHOW_AFTER_SHADOW];
237
264
 
238
- this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
265
+ this.setTimerToSendInitialOverflowCaptured(initialIsOveflowing);
266
+ }
239
267
  }
240
268
 
241
269
  componentWillUnmount() {
@@ -254,6 +282,8 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
254
282
  this.dragAndDropCleanupFn();
255
283
  }
256
284
 
285
+ this.resizeObserver?.disconnect();
286
+
257
287
  const { stickyScrollbar } = getEditorFeatureFlags();
258
288
 
259
289
  if (stickyScrollbar) {
@@ -418,38 +448,42 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
418
448
 
419
449
  this.handleTableResizingDebounced();
420
450
  }
451
+ if (isOverflowAnalyticsEnabled) {
452
+ const newIsOverflowing =
453
+ this.state[ShadowEvent.SHOW_BEFORE_SHADOW] ||
454
+ this.state[ShadowEvent.SHOW_AFTER_SHADOW];
421
455
 
422
- const newIsOverflowing =
423
- this.state[ShadowEvent.SHOW_BEFORE_SHADOW] ||
424
- this.state[ShadowEvent.SHOW_AFTER_SHADOW];
456
+ const prevIsOverflowing =
457
+ prevState[ShadowEvent.SHOW_BEFORE_SHADOW] ||
458
+ prevState[ShadowEvent.SHOW_AFTER_SHADOW];
425
459
 
426
- const prevIsOverflowing =
427
- prevState[ShadowEvent.SHOW_BEFORE_SHADOW] ||
428
- prevState[ShadowEvent.SHOW_AFTER_SHADOW];
429
-
430
- if (this.initialOverflowCaptureTimerId) {
431
- clearTimeout(this.initialOverflowCaptureTimerId);
432
- }
433
-
434
- if (!this.isInitialOverflowSent) {
435
- this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
436
- }
460
+ if (this.initialOverflowCaptureTimerId) {
461
+ clearTimeout(this.initialOverflowCaptureTimerId);
462
+ }
437
463
 
438
- if (this.isInitialOverflowSent && prevIsOverflowing !== newIsOverflowing) {
439
- const {
440
- dispatch,
441
- state: { tr },
442
- } = this.props.view;
464
+ if (!this.isInitialOverflowSent) {
465
+ this.setTimerToSendInitialOverflowCaptured(newIsOverflowing);
466
+ }
443
467
 
444
- dispatch(
445
- tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
446
- isOverflowing: newIsOverflowing,
447
- wasOverflowing: prevIsOverflowing,
448
- editorWidth: this.props.containerWidth.width || 0,
449
- width: this.node.attrs.width || 0,
450
- parentWidth: this.state?.parentWidth || 0,
451
- }),
452
- );
468
+ if (
469
+ this.isInitialOverflowSent &&
470
+ prevIsOverflowing !== newIsOverflowing
471
+ ) {
472
+ const {
473
+ dispatch,
474
+ state: { tr },
475
+ } = this.props.view;
476
+
477
+ dispatch(
478
+ tr.setMeta(META_KEYS.OVERFLOW_STATE_CHANGED, {
479
+ isOverflowing: newIsOverflowing,
480
+ wasOverflowing: prevIsOverflowing,
481
+ editorWidth: this.props.containerWidth.width || 0,
482
+ width: this.node.attrs.width || 0,
483
+ parentWidth: this.state?.parentWidth || 0,
484
+ }),
485
+ );
486
+ }
453
487
  }
454
488
  }
455
489
 
@@ -471,6 +505,12 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
471
505
  }
472
506
  };
473
507
 
508
+ private observeTable(table: HTMLTableElement | null) {
509
+ if (table) {
510
+ this.resizeObserver?.observe(table);
511
+ }
512
+ }
513
+
474
514
  onStickyState = (state: StickyPluginState) => {
475
515
  const pos = this.props.getPos();
476
516
  if (!isValidPosition(pos, this.props.view.state)) {
@@ -539,6 +579,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
539
579
  selection={view.state.selection}
540
580
  headerRowHeight={headerRow ? headerRow.offsetHeight : undefined}
541
581
  stickyHeader={this.state.stickyHeader}
582
+ tableWrapperWidth={this.state.tableWrapperWidth}
542
583
  />
543
584
  );
544
585
  const tableContainerWidth = getTableContainerWidth(node);
@@ -563,6 +604,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
563
604
  tableContainerWidth={tableContainerWidth}
564
605
  isNumberColumnEnabled={node.attrs.isNumberColumnEnabled}
565
606
  getScrollOffset={() => this.wrapper?.scrollLeft || 0}
607
+ tableWrapperHeight={this.state.tableWrapperHeight}
566
608
  />
567
609
  ) : null;
568
610
 
@@ -615,6 +657,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
615
657
  isBreakoutEnabled={options?.isBreakoutEnabled}
616
658
  isNested={isNested}
617
659
  pluginInjectionApi={pluginInjectionApi}
660
+ tableWrapperHeight={this.state.tableWrapperHeight}
618
661
  isTableResizingEnabled={options?.isTableResizingEnabled}
619
662
  isResizing={isResizing}
620
663
  isTableScalingEnabled={isTableScalingEnabled}
@@ -668,6 +711,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
668
711
  if (tableElement !== this.table) {
669
712
  this.table = tableElement;
670
713
  this.createShadowSentinels(this.table);
714
+ this.observeTable(this.table);
671
715
  }
672
716
  }
673
717
  }}
@@ -1,5 +1,5 @@
1
1
  import type { PropsWithChildren } from 'react';
2
- import React, { forwardRef, useCallback, useRef } from 'react';
2
+ import React, { forwardRef, useCallback, useRef, useState } from 'react';
3
3
 
4
4
  import classNames from 'classnames';
5
5
 
@@ -78,6 +78,7 @@ type ResizableTableContainerProps = {
78
78
  isResizing?: boolean;
79
79
  pluginInjectionApi?: PluginInjectionAPI;
80
80
  isTableScalingEnabled?: boolean;
81
+ tableWrapperHeight?: number;
81
82
  };
82
83
 
83
84
  export const ResizableTableContainer = React.memo(
@@ -92,9 +93,11 @@ export const ResizableTableContainer = React.memo(
92
93
  isResizing,
93
94
  pluginInjectionApi,
94
95
  isTableScalingEnabled,
96
+ tableWrapperHeight,
95
97
  }: PropsWithChildren<ResizableTableContainerProps>) => {
96
98
  const containerRef = useRef<HTMLDivElement | null>(null);
97
99
  const tableWidthRef = useRef<number>(akEditorDefaultLayoutWidth);
100
+ const [resizing, setIsResizing] = useState(false);
98
101
 
99
102
  const updateContainerHeight = useCallback((height: number | 'auto') => {
100
103
  // current StickyHeader State is not stable to be fetch.
@@ -108,41 +111,26 @@ export const ResizableTableContainer = React.memo(
108
111
  // 1px is border width but collapse make it 0.5.
109
112
  // -- When sticky header appear, we should add first row height but reduce
110
113
  // collapsed border
111
- containerRef.current?.style.setProperty(
112
- 'height',
113
- typeof height === 'number' ? `${height + 40.5}px` : 'auto',
114
- );
114
+ return typeof height === 'number' ? `${height + 40.5}px` : 'auto';
115
115
  } else {
116
116
  const stickyHeaderHeight =
117
117
  containerRef.current
118
118
  ?.getElementsByTagName('th')[0]
119
119
  .getBoundingClientRect().height || 0;
120
- containerRef.current?.style.setProperty(
121
- 'height',
122
- typeof height === 'number'
123
- ? `${height + stickyHeaderHeight + 39.5}px`
124
- : 'auto',
125
- );
120
+
121
+ return typeof height === 'number'
122
+ ? `${height + stickyHeaderHeight + 39.5}px`
123
+ : 'auto';
126
124
  }
127
125
  }, []);
128
126
 
129
- const resizeObserverRef = useRef(
130
- new ResizeObserver((entries) => {
131
- updateContainerHeight(entries[entries.length - 1].contentRect.height);
132
- }),
133
- );
134
-
135
127
  const onResizeStart = useCallback(() => {
136
- if (tableRef) {
137
- resizeObserverRef.current.observe(tableRef);
138
- }
139
- }, [tableRef]);
128
+ setIsResizing(true);
129
+ }, []);
140
130
 
141
131
  const onResizeStop = useCallback(() => {
142
- updateContainerHeight('auto');
143
-
144
- resizeObserverRef.current.disconnect();
145
- }, [updateContainerHeight]);
132
+ setIsResizing(false);
133
+ }, []);
146
134
 
147
135
  const updateWidth = useCallback((width: number) => {
148
136
  if (!containerRef.current) {
@@ -239,6 +227,9 @@ export const ResizableTableContainer = React.memo(
239
227
  <div
240
228
  style={{
241
229
  width: tableWidthRef.current,
230
+ height: resizing
231
+ ? updateContainerHeight(tableWrapperHeight ?? 'auto')
232
+ : 'auto',
242
233
  }}
243
234
  className={ClassName.TABLE_RESIZER_CONTAINER}
244
235
  ref={containerRef}
@@ -267,6 +258,7 @@ type TableContainerProps = {
267
258
  isResizing?: boolean;
268
259
  pluginInjectionApi?: PluginInjectionAPI;
269
260
  isTableScalingEnabled?: boolean;
261
+ tableWrapperHeight?: number;
270
262
  };
271
263
 
272
264
  export const TableContainer = ({
@@ -280,6 +272,7 @@ export const TableContainer = ({
280
272
  getPos,
281
273
  tableRef,
282
274
  isNested,
275
+ tableWrapperHeight,
283
276
  isResizing,
284
277
  pluginInjectionApi,
285
278
  isTableScalingEnabled,
@@ -293,6 +286,7 @@ export const TableContainer = ({
293
286
  editorView={editorView}
294
287
  getPos={getPos}
295
288
  tableRef={tableRef}
289
+ tableWrapperHeight={tableWrapperHeight}
296
290
  isResizing={isResizing}
297
291
  pluginInjectionApi={pluginInjectionApi}
298
292
  isTableScalingEnabled={isTableScalingEnabled}
@@ -125,10 +125,7 @@ const getResizerHandleHeight = (
125
125
 
126
126
  const getResizerMinWidth = (node: PMNode) => {
127
127
  const currentColumnCount = getColgroupChildrenLength(node);
128
- const minColumnWidth =
129
- currentColumnCount <= 3
130
- ? currentColumnCount * COLUMN_MIN_WIDTH
131
- : 3 * COLUMN_MIN_WIDTH;
128
+ const minColumnWidth = Math.min(3, currentColumnCount) * COLUMN_MIN_WIDTH;
132
129
  // add an extra pixel as the scale table logic will scale columns to be tableContainerWidth - 1
133
130
  // the table can't scale past its min-width, so instead restrict table container min width to avoid that situation
134
131
  return minColumnWidth + 1;
package/src/plugin.tsx CHANGED
@@ -135,10 +135,11 @@ export type TablePlugin = NextEditorPlugin<
135
135
  const tablesPlugin: TablePlugin = ({ config: options, api }) => {
136
136
  const editorViewRef: Record<'current', EditorView | null> = { current: null };
137
137
  const defaultGetEditorContainerWidth: GetEditorContainerWidth = () => {
138
- const defaultState = {
139
- width: document?.body?.offsetWidth ?? 500,
140
- };
141
- return api?.width?.sharedState.currentState() ?? defaultState;
138
+ return (
139
+ api?.width?.sharedState.currentState() ?? {
140
+ width: document?.body?.offsetWidth ?? 500,
141
+ }
142
+ );
142
143
  };
143
144
  const editorAnalyticsAPI = api?.analytics?.actions;
144
145
 
@@ -77,7 +77,6 @@ import TableRow from '../nodeviews/TableRow';
77
77
  import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plugin';
78
78
  import { fixTables, replaceSelectedTable } from '../transforms';
79
79
  import type {
80
- ElementContentRects,
81
80
  InvalidNodeAttr,
82
81
  PluginConfig,
83
82
  PluginInjectionAPI,
@@ -134,19 +133,6 @@ export const createPlugin = (
134
133
  getIntl,
135
134
  });
136
135
 
137
- let elementContentRects: ElementContentRects = {};
138
-
139
- const observer = window?.ResizeObserver
140
- ? new ResizeObserver((entries) => {
141
- entries.forEach((entry) => {
142
- if (!entry.target.id) {
143
- return;
144
- }
145
- elementContentRects[entry.target.id] = entry.contentRect;
146
- });
147
- })
148
- : undefined;
149
-
150
136
  // Used to prevent invalid table cell spans being reported more than once per editor/document
151
137
  const invalidTableIds: string[] = [];
152
138
  let editorViewRef: EditorView | null = null;
@@ -282,11 +268,6 @@ export const createPlugin = (
282
268
  removeResizeHandleDecorations()(state, dispatch);
283
269
  }
284
270
  },
285
- destroy: () => {
286
- if (observer) {
287
- observer.disconnect();
288
- }
289
- },
290
271
  };
291
272
  },
292
273
  props: {
@@ -417,9 +398,9 @@ export const createPlugin = (
417
398
  tableRow: (node, view, getPos) =>
418
399
  new TableRow(node, view, getPos, eventDispatcher),
419
400
  tableCell: (node, view, getPos) =>
420
- new TableCell(node, view, getPos, eventDispatcher, observer),
401
+ new TableCell(node, view, getPos, eventDispatcher),
421
402
  tableHeader: (node, view, getPos) =>
422
- new TableCell(node, view, getPos, eventDispatcher, observer),
403
+ new TableCell(node, view, getPos, eventDispatcher),
423
404
  },
424
405
  handleDOMEvents: {
425
406
  focus: handleFocus,
@@ -428,7 +409,7 @@ export const createPlugin = (
428
409
  mouseover: withCellTracking(whenTableInFocus(handleMouseOver)),
429
410
  mouseleave: handleMouseLeave,
430
411
  mouseout: whenTableInFocus(handleMouseOut),
431
- mousemove: whenTableInFocus(handleMouseMove, elementContentRects),
412
+ mousemove: whenTableInFocus(handleMouseMove),
432
413
  mouseenter: handleMouseEnter,
433
414
  mouseup: whenTableInFocus(handleMouseUp),
434
415
  click: withCellTracking(whenTableInFocus(handleClick)),
package/src/types.ts CHANGED
@@ -447,10 +447,6 @@ export interface ToolbarMenuContext {
447
447
  formatMessage: IntlShape['formatMessage'];
448
448
  }
449
449
 
450
- export type ElementContentRects = {
451
- [key: string]: ResizeObserverEntry['contentRect'];
452
- };
453
-
454
450
  export enum ShadowEvent {
455
451
  SHOW_BEFORE_SHADOW = 'showBeforeShadow',
456
452
  SHOW_AFTER_SHADOW = 'showAfterShadow',
@@ -38,6 +38,7 @@ export interface Props {
38
38
  tableContainerWidth?: number;
39
39
  isNumberColumnEnabled?: boolean;
40
40
  getScrollOffset?: () => number;
41
+ tableWrapperHeight?: number;
41
42
  }
42
43
 
43
44
  export const TableFloatingColumnControls = ({
@@ -55,10 +56,8 @@ export const TableFloatingColumnControls = ({
55
56
  tableContainerWidth,
56
57
  isNumberColumnEnabled,
57
58
  getScrollOffset,
59
+ tableWrapperHeight,
58
60
  }: Props) => {
59
- const [tableRect, setTableRect] = useState<{ width: number; height: number }>(
60
- { width: 0, height: 0 },
61
- );
62
61
  const [isDragging, setIsDragging] = useState(false);
63
62
  const containerRef = useRef<HTMLDivElement>(null);
64
63
 
@@ -70,29 +69,6 @@ export const TableFloatingColumnControls = ({
70
69
  ? stickyHeader.top
71
70
  : undefined;
72
71
 
73
- useEffect(() => {
74
- if (tableRef && window?.ResizeObserver) {
75
- const resizeObserver = new ResizeObserver((entries) => {
76
- for (let entry of entries) {
77
- setTableRect((prev) => {
78
- if (
79
- prev.width !== entry.contentRect.width ||
80
- prev.height !== entry.contentRect.height
81
- ) {
82
- return entry.contentRect;
83
- }
84
- return prev;
85
- });
86
- }
87
- });
88
- resizeObserver.observe(tableRef);
89
-
90
- return () => {
91
- resizeObserver.disconnect();
92
- };
93
- }
94
- }, [tableRef]);
95
-
96
72
  useEffect(() => {
97
73
  return monitorForElements({
98
74
  canMonitor({ source }) {
@@ -115,11 +91,11 @@ export const TableFloatingColumnControls = ({
115
91
 
116
92
  const rowHeights = useMemo(() => {
117
93
  // NOTE: we don't care so much as to what tableHeight is, we only care that it changed and is a sane value.
118
- if (tableRef && !!tableRect.height) {
94
+ if (tableRef && !!tableWrapperHeight) {
119
95
  return getRowHeights(tableRef);
120
96
  }
121
97
  return [0];
122
- }, [tableRef, tableRect.height]);
98
+ }, [tableRef, tableWrapperHeight]);
123
99
 
124
100
  if (!tableRef || !tableActive || isResizing) {
125
101
  return null;
@@ -165,7 +141,7 @@ export const TableFloatingColumnControls = ({
165
141
  <ColumnDropTargets
166
142
  tableRef={tableRef}
167
143
  isHeaderSticky={stickyHeader?.sticky && hasHeaderRow}
168
- tableHeight={tableRect.height}
144
+ tableHeight={tableWrapperHeight}
169
145
  localId={currentNodeLocalId}
170
146
  colWidths={colWidths}
171
147
  getScrollOffset={getScrollOffset}