diff options
author | yipstanley <stanley_yip@brown.edu> | 2019-06-04 14:01:08 -0400 |
---|---|---|
committer | yipstanley <stanley_yip@brown.edu> | 2019-06-04 14:01:08 -0400 |
commit | b33ee6461b4aad420d52600946bee03dcf480e06 (patch) | |
tree | 275e6eaa3beb791a6110522efab79b4fa7a6454a /src/client/views/EditableView.tsx | |
parent | 1fb7a7bc185c1ba9bbe0f21ad5e16cf19235b2da (diff) | |
parent | 7d3ef1c914cc1cc0b6c05b14773a8b83e1b95c96 (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into pdf_impl
Diffstat (limited to 'src/client/views/EditableView.tsx')
-rw-r--r-- | src/client/views/EditableView.tsx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx index 78143ccda..c946d68e1 100644 --- a/src/client/views/EditableView.tsx +++ b/src/client/views/EditableView.tsx @@ -22,7 +22,7 @@ export interface EditableProps { * The contents to render when not editing */ contents: any; - height: number; + height?: number; display?: string; oneLine?: boolean; } @@ -53,6 +53,12 @@ export class EditableView extends React.Component<EditableProps> { } } + @action + onClick = (e: React.MouseEvent) => { + this.editing = true; + e.stopPropagation(); + } + render() { if (this.editing) { return <input className="editableView-input" defaultValue={this.props.GetValue()} onKeyDown={this.onKeyDown} autoFocus onBlur={action(() => this.editing = false)} @@ -60,7 +66,7 @@ export class EditableView extends React.Component<EditableProps> { } else { return ( <div className={`editableView-container-editing${this.props.oneLine ? "-oneLine" : ""}`} style={{ display: this.props.display, height: "auto", maxHeight: `${this.props.height}` }} - onClick={action(() => this.editing = true)} > + onClick={this.onClick} > <span>{this.props.contents}</span> </div> ); |