Skip to content

Commit 0cd9efc

Browse files
committed
Fixed lost undo history by always render editor
Toggle it's visibility instead of not rendering it. Fixes #53
1 parent 43c959a commit 0cd9efc

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/pages/index.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ class Index extends React.Component {
383383

384384
render() {
385385
const { classes } = this.props;
386+
const editorIsOpen = !this.state.nodeFormatDrawerIsOpen && !this.state.edgeFormatDrawerIsOpen;
386387

387388
var columns;
388389
if (this.state.insertPanelsAreOpen && this.state.graphInitialized) {
@@ -472,22 +473,22 @@ class Index extends React.Component {
472473
onColorChange={this.handleEdgeColorChange}
473474
onFillColorChange={this.handleEdgeFillColorChange}
474475
/>
475-
<div>
476-
{this.state.nodeFormatDrawerIsOpen || this.state.edgeFormatDrawerIsOpen || (
477-
<TextEditor
478-
// allocated viewport width - 2 * padding
479-
width={`calc(${columns.textEditor * 100 / 12}vw - 2 * 12px)`}
480-
dotSrc={this.state.dotSrc}
481-
onTextChange={this.handleTextChange}
482-
error={this.state.error}
483-
selectedGraphComponents={this.state.selectedGraphComponents}
484-
holdOff={this.state.holdOff}
485-
fontSize={this.state.fontSize}
486-
tabSize={this.state.tabSize}
487-
registerUndo={this.registerUndo}
488-
registerRedo={this.registerRedo}
489-
/>
490-
)}
476+
<div style={{display: editorIsOpen ? 'block' : 'none'}}>
477+
<TextEditor
478+
// allocated viewport width - 2 * padding
479+
width={`calc(${columns.textEditor * 100 / 12}vw - 2 * 12px)`}
480+
dotSrc={this.state.dotSrc}
481+
onTextChange={this.handleTextChange}
482+
onFocus={this.handleTextEditorFocus}
483+
onBlur={this.handleTextEditorBlur}
484+
error={this.state.error}
485+
selectedGraphComponents={this.state.selectedGraphComponents}
486+
holdOff={this.state.holdOff}
487+
fontSize={this.state.fontSize}
488+
tabSize={this.state.tabSize}
489+
registerUndo={this.registerUndo}
490+
registerRedo={this.registerRedo}
491+
/>
491492
</div>
492493
</Paper>
493494
</Grid>

0 commit comments

Comments
 (0)