aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/EditableView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/EditableView.tsx')
-rw-r--r--src/client/views/EditableView.tsx17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index a8cfc4fcb..31e4557be 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -39,6 +39,7 @@ export interface EditableProps {
oneLine?: boolean;
editing?: boolean;
onClick?: (e: React.MouseEvent) => boolean;
+ isEditingCallback?: (isEditing: boolean) => void;
}
/**
@@ -56,6 +57,16 @@ export class EditableView extends React.Component<EditableProps> {
}
@action
+ componentWillReceiveProps(nextProps: EditableProps) {
+ // this is done because when autosuggest is turned on, the suggestions are passed in as a prop,
+ // so when the suggestions are passed in, and no editing prop is passed in, it used to set it
+ // to false. this will no longer do so -syip
+ if (nextProps.editing && nextProps.editing !== this._editing) {
+ this._editing = nextProps.editing;
+ }
+ }
+
+ @action
onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === "Tab") {
this.props.OnTab && this.props.OnTab();
@@ -63,13 +74,16 @@ export class EditableView extends React.Component<EditableProps> {
if (!e.ctrlKey) {
if (this.props.SetValue(e.currentTarget.value, e.shiftKey)) {
this._editing = false;
+ this.props.isEditingCallback && this.props.isEditingCallback(false);
}
} else if (this.props.OnFillDown) {
this.props.OnFillDown(e.currentTarget.value);
this._editing = false;
+ this.props.isEditingCallback && this.props.isEditingCallback(false);
}
} else if (e.key === "Escape") {
this._editing = false;
+ this.props.isEditingCallback && this.props.isEditingCallback(false);
}
}
@@ -78,6 +92,7 @@ export class EditableView extends React.Component<EditableProps> {
e.nativeEvent.stopPropagation();
if (!this.props.onClick || !this.props.onClick(e)) {
this._editing = true;
+ this.props.isEditingCallback && this.props.isEditingCallback(true);
}
e.stopPropagation();
}
@@ -109,7 +124,7 @@ export class EditableView extends React.Component<EditableProps> {
}}
/>
: <input className="editableView-input" defaultValue={this.props.GetValue()} onKeyDown={this.onKeyDown} autoFocus
- onBlur={action(() => this._editing = false)} onPointerDown={this.stopPropagation} onClick={this.stopPropagation} onPointerUp={this.stopPropagation}
+ onBlur={action(() => { this._editing = false; this.props.isEditingCallback && this.props.isEditingCallback(false); })} onPointerDown={this.stopPropagation} onClick={this.stopPropagation} onPointerUp={this.stopPropagation}
style={{ display: this.props.display, fontSize: this.props.fontSize }} />;
} else {
if (this.props.autosuggestProps) this.props.autosuggestProps.resetValue();