fix: Fix bug that could cause errant line when rendering. by gonfunko · Pull Request #9333 · RaspberryPiFoundation/blockly

The basics

The details

Resolves

Fixes #6028

Proposed Changes

This PR updates the drawer to not include the ascender height (which goes negative/above the starting point of a top row, e.g. for hats) when drawing a vertical path downwards to complete the right edge of the top row. Under certain circumstances, this could exceed the total height of the block and appear as a stray dangly line on the bottom right corner.

There is actually at least 3x redundancy for parts of the right edge of a block path in practice, since the top/bottom rows don't have additional height beyond that caused by their rounded corners/notches/hat. However, because they could, the top and bottom rows draw a vertical line corresponding to the row's total height along the right edge of the block. These generally overlap the middle rows of blocks and are thus not visible, but #6469 tracks cleaning them up. In theory the top/bottom row drawing methods could track the vertical delta between the starting point and ending point when drawing each element in the row, and subtract that from the overall row height to draw the exact amount needed, but this would be a large refactor and I think requires either writing an SVG path parser to evaluate the height of a path fragment, or making breaking changes to the interfaces for e.g. hats, which currently don't know their height outside of what is encoded in the path.