From 0e8a7409eadc4c261f4e47cfaddd001e425f77d9 Mon Sep 17 00:00:00 2001 From: mehekj Date: Thu, 16 Feb 2023 10:15:13 -0500 Subject: preview fixes --- .../collectionSchema/CollectionSchemaView.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index 5d4777e12..64c39cf1a 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -42,6 +42,7 @@ export class CollectionSchemaView extends CollectionSubView() { private _selectedDocSortedArray: Doc[] = []; private _closestDropIndex: number = 0; private _minColWidth: number = 150; + private _previewRef: HTMLDivElement | null = null; public static _rowMenuWidth: number = 100; public static _previewDividerWidth: number = 4; @@ -71,7 +72,7 @@ export class CollectionSchemaView extends CollectionSubView() { } @computed get tableWidth() { - return this.props.PanelWidth() - this.previewWidth - CollectionSchemaView._previewDividerWidth; + return this.props.PanelWidth() - this.previewWidth - (this.previewWidth === 0 ? 0 : CollectionSchemaView._previewDividerWidth); } @computed get columnKeys() { @@ -405,12 +406,12 @@ export class CollectionSchemaView extends CollectionSubView() { @action onDividerMove = (e: PointerEvent, down: number[], delta: number[]) => { - // const nativeWidth = this._previewCont!.getBoundingClientRect(); - // const minWidth = 40; - // const maxWidth = 1000; - // const movedWidth = this.props.ScreenToLocalTransform().transformDirection(nativeWidth.right - e.clientX, 0)[0]; - // const width = movedWidth < minWidth ? minWidth : movedWidth > maxWidth ? maxWidth : movedWidth; - this.props.Document.schemaPreviewWidth = this.previewWidth - delta[0]; + const nativeWidth = this._previewRef!.getBoundingClientRect(); + const minWidth = 40; + const maxWidth = 1000; + const movedWidth = this.props.ScreenToLocalTransform().transformDirection(nativeWidth.right - e.clientX, 0)[0]; + const width = movedWidth < minWidth ? minWidth : movedWidth > maxWidth ? maxWidth : movedWidth; + this.props.Document.schemaPreviewWidth = width; return false; }; @@ -566,9 +567,9 @@ export class CollectionSchemaView extends CollectionSubView() { -
+ {this.previewWidth > 0 &&
} {this.previewWidth > 0 && ( -
+
(this._previewRef = ref)}> {this._previewDoc && (