aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/EditableView.tsx
diff options
context:
space:
mode:
authorStanley Yip <stanley_yip@brown.edu>2020-01-08 13:47:29 -0500
committerStanley Yip <stanley_yip@brown.edu>2020-01-08 13:47:29 -0500
commitabfa42b6f2cf863deee19aac19328a23687464cb (patch)
treeb481f23ffa7bccbde7a31de34f50d765b6b73162 /src/client/views/EditableView.tsx
parentd8fc218f3481728f221ceacc60ac4bc553f8e295 (diff)
parent19a71cb2788b9c1c8d8ced4af285bf91033ba626 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into pen
Diffstat (limited to 'src/client/views/EditableView.tsx')
-rw-r--r--src/client/views/EditableView.tsx12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index 8e86f58ee..54def38b5 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -10,7 +10,7 @@ export interface EditableProps {
/**
* Called to get the initial value for editing
* */
- GetValue(): string;
+ GetValue(): string | undefined;
/**
* Called to apply changes
@@ -21,7 +21,7 @@ export interface EditableProps {
OnFillDown?(value: string): void;
- OnTab?(): void;
+ OnTab?(shift?: boolean): void;
/**
* The contents to render when not editing
@@ -79,7 +79,7 @@ export class EditableView extends React.Component<EditableProps> {
if (e.key === "Tab") {
e.stopPropagation();
this.finalizeEdit(e.currentTarget.value, e.shiftKey);
- this.props.OnTab && this.props.OnTab();
+ this.props.OnTab && this.props.OnTab(e.shiftKey);
} else if (e.key === "Enter") {
e.stopPropagation();
if (!e.ctrlKey) {
@@ -108,8 +108,8 @@ export class EditableView extends React.Component<EditableProps> {
@action
private finalizeEdit(value: string, shiftDown: boolean) {
+ this._editing = false;
if (this.props.SetValue(value, shiftDown)) {
- this._editing = false;
this.props.isEditingCallback && this.props.isEditingCallback(false);
}
}
@@ -120,11 +120,13 @@ export class EditableView extends React.Component<EditableProps> {
@action
setIsFocused = (value: boolean) => {
+ const wasFocused = this._editing;
this._editing = value;
+ return wasFocused !== this._editing;
}
render() {
- if (this._editing) {
+ if (this._editing && this.props.GetValue() !== undefined) {
return this.props.autosuggestProps
? <Autosuggest
{...this.props.autosuggestProps.autosuggestProps}