aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/EditableView.tsx
diff options
context:
space:
mode:
authorSophie Zhang <sophie_zhang@brown.edu>2024-02-22 10:22:58 -0500
committerSophie Zhang <sophie_zhang@brown.edu>2024-02-22 10:22:58 -0500
commit3f33a680af31a04b58c6163fda53a80a737837c6 (patch)
treeb84da40da1c13c8ab8ab8cd763b69ac5b39ce93c /src/client/views/EditableView.tsx
parent70cf5ad795055c1f628c918b08a13a96e4ab89a6 (diff)
parentcf85ee4ea73985529a16321d671d893ddb862439 (diff)
Merge branch 'master' into sophie-ai-images
Diffstat (limited to 'src/client/views/EditableView.tsx')
-rw-r--r--src/client/views/EditableView.tsx17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index 73ac1b032..4508d00a7 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -1,4 +1,4 @@
-import { action, IReactionDisposer, makeObservable, observable, reaction } from 'mobx';
+import { action, IReactionDisposer, makeObservable, observable, reaction, runInAction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import * as Autosuggest from 'react-autosuggest';
@@ -97,9 +97,10 @@ export class EditableView extends ObservableReactComponent<EditableProps> {
super.componentDidUpdate(prevProps);
if (this._editing && this._props.editing === false) {
this._inputref?.value && this.finalizeEdit(this._inputref.value, false, true, false);
- } else if (this._props.editing !== undefined) {
- this._editing = this._props.editing;
- }
+ } else
+ runInAction(() => {
+ if (this._props.editing !== undefined) this._editing = this._props.editing;
+ });
}
componentWillUnmount() {
@@ -248,7 +249,6 @@ export class EditableView extends ObservableReactComponent<EditableProps> {
autoFocus={true}
onChange={this.onChange}
onKeyDown={this.onKeyDown}
- onKeyPress={this.stopPropagation}
onPointerDown={this.stopPropagation}
onClick={this.stopPropagation}
onPointerUp={this.stopPropagation}
@@ -264,7 +264,6 @@ export class EditableView extends ObservableReactComponent<EditableProps> {
autoFocus={true}
onChange={this.onChange}
onKeyDown={this.onKeyDown}
- onKeyPress={this.stopPropagation}
onPointerDown={this.stopPropagation}
onClick={this.stopPropagation}
onPointerUp={this.stopPropagation}
@@ -299,15 +298,13 @@ export class EditableView extends ObservableReactComponent<EditableProps> {
fontStyle: this._props.fontStyle,
fontSize: this._props.fontSize,
}}
- //onPointerDown={this.stopPropagation}
- onClick={this.onClick}
- placeholder={this._props.placeholder}>
+ onClick={this.onClick}>
<span
style={{
fontStyle: this._props.fontStyle,
fontSize: this._props.fontSize,
}}>
- {this._props.fieldContents ? <FieldView {...this._props.fieldContents} /> : this.props.contents ? this._props.contents?.valueOf() : this._props.placeholder?.valueOf()}
+ {this._props.fieldContents ? <FieldView {...this._props.fieldContents} /> : this.props.contents ? this._props.contents?.valueOf() : ''}
</span>
</div>
);