Merge pull request #11178 from keymanapp/fix/web/nearest-key-row-lookup

This commit is contained in:
Joshua Horton 2024-04-09 19:01:56 +07:00 committed by GitHub
commit c48dcbab47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -198,7 +198,7 @@ export default class OSKLayerGroup {
Assumes there is no fine-tuning of the row ranges to be done - each takes a perfect
fraction of the overall layer height without any padding above or below.
*/
const rowIndex = Math.floor(proportionalCoords.y * layer.rows.length);
const rowIndex = Math.max(0, Math.min(layer.rows.length-1, Math.floor(proportionalCoords.y * layer.rows.length)));
const row = layer.rows[rowIndex];
// Assertion: row no longer `null`.