aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-06-25 13:49:35 -0400
committerNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-06-25 13:49:35 -0400
commita9494a1959430ffb3f501ef59f699aabc3748c7d (patch)
tree81a8af82872b9afd8fb1372b3bdc141f58a6681c
parentf8232f2d210df5dcce352a51df7079095b1d1123 (diff)
changing cursor position updates refselectmode
-rw-r--r--src/client/views/collections/collectionSchema/SchemaCellField.tsx5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/client/views/collections/collectionSchema/SchemaCellField.tsx b/src/client/views/collections/collectionSchema/SchemaCellField.tsx
index 72d89adc3..7bdfaa587 100644
--- a/src/client/views/collections/collectionSchema/SchemaCellField.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaCellField.tsx
@@ -219,6 +219,7 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
};
onChange = (e: FormEvent<HTMLDivElement> | undefined, newText?: string) => {
+ console.log('onchange called')
const prevVal = this._unrenderedContent;
const targVal = newText ?? e!.currentTarget.innerText; // TODO: bang
if (!(targVal.startsWith(':=') || targVal.startsWith('='))) {
@@ -230,6 +231,7 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
this._unrenderedContent = targVal;
this._props.highlightCells?.(targVal);
if (this.shouldUpdate(prevVal, targVal)) {this.setContent(targVal, true)};
+ console.log('cursorpos: ' + this.cursorPosition + ' char: ' + this.lastCharBeforeCursor);
this.setupRefSelect(this.refSelectConditionMet);
};
@@ -262,6 +264,7 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
break;
case 'ArrowUp': case 'ArrowDown': case 'ArrowLeft': case 'ArrowRight': // prettier-ignore
e.stopPropagation();
+ setTimeout(() => this.setupRefSelect(this.refSelectConditionMet), 0)
break;
case ' ':
e.stopPropagation();
@@ -330,7 +333,7 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
autoFocus
onInput={this.onChange}
onKeyDown={this.onKeyDown}
- onPointerDown={e => e.stopPropagation}
+ onPointerDown={e => {e.stopPropagation(); setTimeout(() => this.setupRefSelect(this.refSelectConditionMet), 0)}} //timeout callback ensures that refSelectMode is properly set
onClick={e => e.stopPropagation}
onPointerUp={e => e.stopPropagation}
onPointerMove={e => {e.stopPropagation(); e.preventDefault()}}