ensure restored elements are normalized before filter (#844)

This commit is contained in:
David Luzar 2020-02-27 17:37:43 +01:00 committed by GitHub
parent a8a5733e50
commit 7e0e885417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -343,7 +343,6 @@ function restore(
opts?: { scrollToContent: boolean }, opts?: { scrollToContent: boolean },
): DataState { ): DataState {
const elements = savedElements const elements = savedElements
.filter(el => !isInvisiblySmallElement(el))
.map(element => { .map(element => {
let points: Point[] = []; let points: Point[] = [];
if (element.type === "arrow") { if (element.type === "arrow") {
@ -392,7 +391,8 @@ function restore(
canvasOffsetX: element.canvasOffsetX || 0, canvasOffsetX: element.canvasOffsetX || 0,
canvasOffsetY: element.canvasOffsetY || 0, canvasOffsetY: element.canvasOffsetY || 0,
}; };
}); })
.filter(el => !isInvisiblySmallElement(el));
if (opts?.scrollToContent && savedState) { if (opts?.scrollToContent && savedState) {
savedState = { ...savedState, ...calculateScrollCenter(elements) }; savedState = { ...savedState, ...calculateScrollCenter(elements) };