projectstorm / react-diagrams

a super simple, no-nonsense diagramming library written in react that just works
https://projectstorm.cloud/react-diagrams
MIT License
8.71k stars 1.18k forks source link

fix: closes #665. guard against null elements #668

Closed tkolanko closed 4 years ago

tkolanko commented 4 years ago

Checklist

What?

Element events can potentially be null if they trigger a dialog to appear when clicked Fixes #665

Why?

When you close a dialog created by clicking an element and go to interact with the canvas this event will fire: https://github.com/projectstorm/react-diagrams/blob/ce38f77027ac37ca9193c6faccc6049036906e42/packages/react-canvas-core/src/states/MoveItemsState.ts#L24-L25 which calls https://github.com/projectstorm/react-diagrams/blob/655462087f1f54eccb5e75f024be00efda674eab/packages/react-canvas-core/src/core-actions/ActionEventBus.ts#L41-L46 which checks if a model exists and if it doesn't it will return https://github.com/projectstorm/react-diagrams/blob/655462087f1f54eccb5e75f024be00efda674eab/packages/react-canvas-core/src/CanvasEngine.ts#L178-L180 which returns null

How?

Added an early return if the element is null

Feel good image:

image