From f8232f2d210df5dcce352a51df7079095b1d1123 Mon Sep 17 00:00:00 2001 From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:17:54 -0400 Subject: enhanced refselect logic --- .../collectionSchema/CollectionSchemaView.tsx | 3 --- .../collectionSchema/SchemaCellField.tsx | 28 +++++++++++----------- 2 files changed, 14 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx index 32106e3be..583829d6c 100644 --- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx +++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx @@ -296,7 +296,6 @@ export class CollectionSchemaView extends CollectionSubView() { break; } case 'P': { - console.log(this._cellHighlightColors) break; } default: @@ -687,14 +686,12 @@ export class CollectionSchemaView extends CollectionSubView() { @action deselectCell = (doc: Doc) => { - console.log('single deselect called') this._selectedCells && (this._selectedCells = this._selectedCells.filter(d => d !== doc)); if (this.rowIndex(doc) === this._lowestSelectedIndex) this._lowestSelectedIndex = Math.min(...this._selectedDocs.map(d => this.rowIndex(d))); }; @action deselectAllCells = () => { - console.log('deselectall called') this._selectedCells = []; this._lowestSelectedIndex = -1; }; diff --git a/src/client/views/collections/collectionSchema/SchemaCellField.tsx b/src/client/views/collections/collectionSchema/SchemaCellField.tsx index 8c4c1cd76..72d89adc3 100644 --- a/src/client/views/collections/collectionSchema/SchemaCellField.tsx +++ b/src/client/views/collections/collectionSchema/SchemaCellField.tsx @@ -57,6 +57,11 @@ export class SchemaCellField extends ObservableReactComponent this._editing, editing => { if (editing) { - if (this.lastCharBeforeCursor !== '+') this.setupRefSelect(false); + this.setupRefSelect(this.refSelectConditionMet); setTimeout(() => { if (this._inputref?.innerText.startsWith('=') || this._inputref?.innerText.startsWith(':=')) { this._overlayDisposer?.(); this._overlayDisposer = OverlayView.Instance.addElement(, { x: 0, y: 0 }); this._props.highlightCells?.(this._unrenderedContent); - this.setContent(this._unrenderedContent, true); + this.setContent(this._unrenderedContent); + setTimeout(() => this.setCursorPosition(this._unrenderedContent.length), 0); } }); } else { @@ -139,11 +145,9 @@ export class SchemaCellField extends ObservableReactComponent { + const pos = this.cursorPosition; this._displayedContent = this.makeSpans(content); - if (restoreCursorPos) { - const cursorPos = this.cursorPosition; - setTimeout(() => this.restoreCursorPosition(cursorPos), 0); - } + restoreCursorPos && setTimeout(() => this.setCursorPosition(pos), 0); } @action @@ -153,7 +157,7 @@ export class SchemaCellField extends ObservableReactComponent this.restoreCursorPosition(robustPos + text.length), 0); + setTimeout(() => this.setCursorPosition(robustPos + text.length), 0); } @action @@ -173,12 +177,10 @@ export class SchemaCellField extends ObservableReactComponent { + setCursorPosition = (position: number | null) => { const selection = window.getSelection(); if (!selection || position === null || !this._inputref) return; @@ -228,9 +230,7 @@ export class SchemaCellField extends ObservableReactComponent { @@ -269,7 +269,7 @@ export class SchemaCellField extends ObservableReactComponent { this.setContent(this._unrenderedContent); - setTimeout(() => this.restoreCursorPosition(cursorPos), 0); + setTimeout(() => this.setCursorPosition(cursorPos), 0); } , 0); break; -- cgit v1.2.3-70-g09d2