From eb441419bad5468f44d36e23cc8cbbf3fd096b08 Mon Sep 17 00:00:00 2001 From: limzykenneth Date: Thu, 18 Jul 2024 16:53:27 +0100 Subject: [PATCH] Skip out of canvas shapes for gridOutput() table --- src/accessibility/gridOutput.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/accessibility/gridOutput.js b/src/accessibility/gridOutput.js index e0a62ddbef..5b52a23eb8 100644 --- a/src/accessibility/gridOutput.js +++ b/src/accessibility/gridOutput.js @@ -62,19 +62,26 @@ function _gridMap(idT, ingredients) { ingredients[x][y].color } ${x} midpoint`; } - //if empty cell of location of shape is undefined - if (!cells[ingredients[x][y].loc.locY][ingredients[x][y].loc.locX]) { - //fill it with shape info - cells[ingredients[x][y].loc.locY][ingredients[x][y].loc.locX] = fill; - //if a shape is already in that location - } else { - //add it - cells[ingredients[x][y].loc.locY][ingredients[x][y].loc.locX] = - cells[ingredients[x][y].loc.locY][ingredients[x][y].loc.locX] + - ' ' + - fill; + + // Check if shape is in canvas, skip if not + if( + ingredients[x][y].loc.locY < cells.length && + ingredients[x][y].loc.locX < cells[ingredients[x][y].loc.locY].length + ){ + //if empty cell of location of shape is undefined + if (!cells[ingredients[x][y].loc.locY][ingredients[x][y].loc.locX]) { + //fill it with shape info + cells[ingredients[x][y].loc.locY][ingredients[x][y].loc.locX] = fill; + //if a shape is already in that location + } else { + //add it + cells[ingredients[x][y].loc.locY][ingredients[x][y].loc.locX] = + cells[ingredients[x][y].loc.locY][ingredients[x][y].loc.locX] + + ' ' + + fill; + } + shapeNumber++; } - shapeNumber++; } } //make table based on array