aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2020-10-21 10:24:07 -0400
committerbobzel <zzzman@gmail.com>2020-10-21 10:24:07 -0400
commit55053983adc5b1b29efa0b2f38df5a58dfb93d42 (patch)
treeb417eb10d1033a9987125af44a82e7560e2292e8 /src
parentfd2f3b137051586850fd28cb6407bb657d77b365 (diff)
fixed editableView to commit current text on unmount (allows slide titles to be committed when clicking on another slide's title)
Diffstat (limited to 'src')
-rw-r--r--src/client/views/EditableView.tsx9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index 8b1b12365..afdda2aff 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -87,6 +87,10 @@ export class EditableView extends React.Component<EditableProps> {
DragManager.MakeDropTarget(this._ref.current, this.props.onDrop.bind(this));
}
}
+ @action
+ componentWillUnmount() {
+ this._inputref.current?.value && this.finalizeEdit(this._inputref.current.value, false, true, false)
+ }
_didShow = false;
@@ -168,6 +172,7 @@ export class EditableView extends React.Component<EditableProps> {
}
_ref = React.createRef<HTMLDivElement>();
+ _inputref = React.createRef<HTMLInputElement>();
renderEditor() {
return this.props.autosuggestProps
? <Autosuggest
@@ -185,7 +190,7 @@ export class EditableView extends React.Component<EditableProps> {
onChange: this.props.autosuggestProps.onChange
}}
/>
- : <input className="editableView-input"
+ : <input className="editableView-input" ref={this._inputref}
defaultValue={this.props.GetValue()}
onKeyDown={this.onKeyDown}
autoFocus={true}
@@ -213,7 +218,7 @@ export class EditableView extends React.Component<EditableProps> {
<div className={`editableView-container-editing${this.props.oneLine ? "-oneLine" : ""}`} ref={this._ref}
style={{ display: this.props.display, minHeight: "17px", whiteSpace: "nowrap", height: this.props.height || "auto", maxHeight: this.props.maxHeight }}
onClick={this.onClick} placeholder={this.props.placeholder}>
- <span style={{ fontStyle: this.props.fontStyle, fontSize: this.props.fontSize }}>{
+ <span style={{ fontStyle: this.props.fontStyle, fontSize: this.props.fontSize }} >{
this.props.contents ? this.props.contents?.valueOf() : this.props.placeholder?.valueOf()}
</span>
</div>;