Skip to content

Commit

Permalink
Remove now-unused cell wrapper observer
Browse files Browse the repository at this point in the history
- we're exclusively watching the cell content now for both auto and line count heights
  • Loading branch information
cee-chen committed Oct 29, 2021
1 parent 2039dde commit 2d9edf4
Showing 1 changed file with 3 additions and 30 deletions.
33 changes: 3 additions & 30 deletions src/components/datagrid/body/data_grid_cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export class EuiDataGridCell extends Component<
static activeFocusTimeoutId: number | undefined = undefined;

cellRef = createRef() as MutableRefObject<HTMLDivElement | null>;
observer!: any; // Cell ResizeObserver
contentObserver!: any; // Cell Content ResizeObserver
popoverPanelRef: MutableRefObject<HTMLElement | null> = createRef();
cellContentsRef: HTMLDivElement | null = null;
Expand All @@ -130,33 +129,6 @@ export class EuiDataGridCell extends Component<
focusTimeout: number | undefined;
style = null;

observeHeight = (
component: HTMLDivElement | null,
setRowHeight?: (rowHeight: number) => void
) => {
const observer = new (window as any).ResizeObserver(() => {
const rowHeight = component!.getBoundingClientRect().height;
if (setRowHeight) {
setRowHeight(rowHeight);
}
});
observer.observe(component);
return observer;
};

setCellRef = (ref: HTMLDivElement | null) => {
this.cellRef.current = ref;

// watch the first cell for size changes and use that to re-compute row heights
if (this.props.colIndex === 0 && this.props.visibleRowIndex === 0) {
if (ref && hasResizeObserver) {
this.observer = this.observeHeight(ref, this.props.setRowHeight);
} else if (this.observer) {
this.observer.disconnect();
}
}
};

static contextType = DataGridFocusContext;

getInteractables = () => {
Expand Down Expand Up @@ -311,10 +283,11 @@ export class EuiDataGridCell extends Component<
setCellContentsRef = (ref: HTMLDivElement | null) => {
this.cellContentsRef = ref;
if (ref && hasResizeObserver) {
this.contentObserver = this.observeHeight(ref, () => {
this.contentObserver = new (window as any).ResizeObserver(() => {
this.recalculateRowHeight();
this.recalculateLineCountHeight();
});
this.contentObserver.observe(ref);
} else if (this.contentObserver) {
this.contentObserver.disconnect();
}
Expand Down Expand Up @@ -586,7 +559,7 @@ export class EuiDataGridCell extends Component<
tabIndex={
this.state.isFocused && !this.state.disableCellTabIndex ? 0 : -1
}
ref={this.setCellRef}
ref={this.cellRef}
{...cellProps}
data-test-subj="dataGridRowCell"
onKeyDown={handleCellKeyDown}
Expand Down

0 comments on commit 2d9edf4

Please sign in to comment.