From 830121ffc5d3d7ba9c5bd48771b6927d24dfce59 Mon Sep 17 00:00:00 2001 From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> Date: Wed, 26 Jun 2024 13:10:47 -0400 Subject: removing 0s from settimeut + minor sorted col highlight color change --- .../collectionSchema/CollectionSchemaView.tsx | 4 ++-- .../collectionSchema/SchemaCellField.tsx | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index 583829d6c..57327a008 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -206,7 +206,7 @@ export class CollectionSchemaView extends CollectionSubView() { ) this._disposers.sortHighlight = reaction( () => [this.sortField, this._docs, this._selectedDocs, this._highlightedCellsInfo], - () => {this.sortField && setTimeout(() => this.highlightSortedColumn(), 0)}, + () => {this.sortField && setTimeout(() => this.highlightSortedColumn())}, {fireImmediately: true} ) } @@ -505,7 +505,7 @@ export class CollectionSchemaView extends CollectionSubView() { if (field || this.sortField){ index = this.columnKeys.indexOf(field || this.sortField); const increment: number = 100/rowCount; - for (let i = 0; i < rowCount; ++i){ + for (let i = 1; i <= rowCount; ++i){ const adjColor = ClientUtils.lightenRGB(16, 66, 230, increment * i); highlightColors.push(`solid 2px rgb(${adjColor[0]}, ${adjColor[1]}, ${adjColor[2]})`); } diff --git a/src/client/views/collections/collectionSchema/SchemaCellField.tsx b/src/client/views/collections/collectionSchema/SchemaCellField.tsx index 7bdfaa587..8e751f4ba 100644 --- a/src/client/views/collections/collectionSchema/SchemaCellField.tsx +++ b/src/client/views/collections/collectionSchema/SchemaCellField.tsx @@ -40,11 +40,13 @@ export class SchemaCellField extends ObservableReactComponent { this._unrenderedContent = this._props.GetValue() ?? ''; this.setContent(this._unrenderedContent); - }, 0); //must be moved to end of batch or else other docs aren't loaded, so render as d-1 in function + }); //must be moved to end of batch or else other docs aren't loaded, so render as d-1 in function } get docIndex(){return DocumentView.getDocViewIndex(this._props.Document);} // prettier-ignore + get selfRefPattern() {return `d${this.docIndex}.${this._props.fieldKey}`}; + @computed get lastCharBeforeCursor(){ const pos = this.cursorPosition; const content = this._unrenderedContent; @@ -76,7 +78,7 @@ export class SchemaCellField extends ObservableReactComponent, { x: 0, y: 0 }); this._props.highlightCells?.(this._unrenderedContent); this.setContent(this._unrenderedContent); - setTimeout(() => this.setCursorPosition(this._unrenderedContent.length), 0); + setTimeout(() => this.setCursorPosition(this._unrenderedContent.length)); } }); } else { @@ -114,7 +116,8 @@ export class SchemaCellField extends ObservableReactComponent { - return `${text}` + const selfRef = text === this.selfRefPattern; + return `${text}`; } makeSpans = (content: string) => { @@ -147,7 +150,7 @@ export class SchemaCellField extends ObservableReactComponent { const pos = this.cursorPosition; this._displayedContent = this.makeSpans(content); - restoreCursorPos && setTimeout(() => this.setCursorPosition(pos), 0); + restoreCursorPos && setTimeout(() => this.setCursorPosition(pos)); } @action @@ -157,7 +160,7 @@ export class SchemaCellField extends ObservableReactComponent this.setCursorPosition(robustPos + text.length), 0); + setTimeout(() => this.setCursorPosition(robustPos + text.length)); } @action @@ -219,7 +222,6 @@ export class SchemaCellField extends ObservableReactComponent | undefined, newText?: string) => { - console.log('onchange called') const prevVal = this._unrenderedContent; const targVal = newText ?? e!.currentTarget.innerText; // TODO: bang if (!(targVal.startsWith(':=') || targVal.startsWith('='))) { @@ -231,7 +233,6 @@ export class SchemaCellField extends ObservableReactComponent { this.setContent(this._unrenderedContent); - setTimeout(() => this.setCursorPosition(cursorPos), 0); + setTimeout(() => this.setCursorPosition(cursorPos)); } , 0); break; @@ -298,7 +299,10 @@ export class SchemaCellField extends ObservableReactComponent