Skip to content
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

fix: Stop throwing errors when calling removeToolState if toolData or… #1181

Merged
merged 3 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,8 @@
"[markdown]": {
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 80
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
5 changes: 5 additions & 0 deletions src/stateManagement/toolState.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ function getToolState(element, toolType) {
function removeToolState(element, toolType, data) {
const toolStateManager = getElementToolStateManager(element);
const toolData = toolStateManager.get(element, toolType);

if (!toolData || !toolData.data || !toolData.data.length) {
return;
}

// Find this tool data
let indexOfData = -1;

Expand Down
8 changes: 5 additions & 3 deletions src/tools/OverlayTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ export default class OverlayTool extends BaseTool {
}

// Guard against non-number values
const overlayX = (!isNaN(parseFloat(overlay.x)) && isFinite(overlay.x)) ? overlay.x : 0;
const overlayY = (!isNaN(parseFloat(overlay.y)) && isFinite(overlay.y)) ? overlay.y : 0;

const overlayX =
!isNaN(parseFloat(overlay.x)) && isFinite(overlay.x) ? overlay.x : 0;
const overlayY =
!isNaN(parseFloat(overlay.y)) && isFinite(overlay.y) ? overlay.y : 0;
// Draw the overlay layer onto the canvas

canvasContext.drawImage(layerCanvas, overlayX, overlayY);
});
}
Expand Down