mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: scene not initialized properly when tab not focused (#2677)
Co-authored-by: Lipis <lipiridis@gmail.com>
This commit is contained in:
parent
0cf58adb4c
commit
aef3644c93
3 changed files with 20 additions and 16 deletions
|
@ -861,7 +861,16 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|||
|
||||
history.record(this.state, this.scene.getElementsIncludingDeleted());
|
||||
|
||||
this.props.onChange?.(this.scene.getElementsIncludingDeleted(), this.state);
|
||||
// Do not notify consumers if we're still loading the scene. Among other
|
||||
// potential issues, this fixes a case where the tab isn't focused during
|
||||
// init, which would trigger onChange with empty elements, which would then
|
||||
// override whatever is in localStorage currently.
|
||||
if (!this.state.isLoading) {
|
||||
this.props.onChange?.(
|
||||
this.scene.getElementsIncludingDeleted(),
|
||||
this.state,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy/paste
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue