Skip to content

Test undo / redo w/ unmount #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Test undo / redo w/ unmount #13

wants to merge 1 commit into from

Conversation

scottdover
Copy link

@scottdover scottdover commented Oct 6, 2022

Summary

This demonstrates an issue w/ undo / redo when a diagram is unmounted / remounted. You can follow the steps below to reproduce:

  • Run yarn start
  • Drag a node somewhere on the diagram
  • See that you can undo it
  • Drag the node again
  • toggle the display off
  • toggle the display on
  • At this point, the nodes position will have been persisted. However, there is no longer an option to undo the position change

One thing I attempted to resolve the issue was to add...

public componentDidUnmount() {
    this.diagramRef.current &&
        this.diagramRef.current.clear();
}

to DiagramWrapper (after reading "A Note on Diagram Reinitialization" here: https://gojs.net/latest/intro/react.html). This unfortunately didn't resolve the issue.

@jonchardy
Copy link
Contributor

This is intentional behavior of gojs-react. The diagram is forgotten when unmounted such that memory isn't held when the diagram is no longer in use.

If you want to persist the diagram when mounting/unmounting, you'll probably want to fork the gojs-react repository and change the behavior of componentDidMount and componentWillUnmount. The implementation is described here: https://github.com/NorthwoodsSoftware/gojs-react/blob/master/IMPLEMENTATION.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants