fix(app): stabilize canvas refresh and borders
Fast Refresh preserves refs while rerunning effects, so canceled paint requests must release their retained IDs or unseen diff regions stop rendering. Paint the final expanded body’s reserved boundary pixel because no following header owns that seam.
This commit is contained in:
@@ -209,15 +209,7 @@ export function DiffSurface(props: DiffSurfaceProps) {
|
||||
}, [loadedTypography, measurement, props.palette, viewport.height, viewport.width]);
|
||||
const schedulePaint = useCallback(
|
||||
(force = true) => {
|
||||
if (force) {
|
||||
forcePaintRef.current = true;
|
||||
// Fast Refresh preserves refs. A request owned by the previous module can leave a stale
|
||||
// id behind, which would otherwise prevent every subsequent canvas repaint.
|
||||
if (frameRef.current !== null) {
|
||||
cancelAnimationFrame(frameRef.current);
|
||||
frameRef.current = null;
|
||||
}
|
||||
}
|
||||
if (force) forcePaintRef.current = true;
|
||||
if (frameRef.current === null) frameRef.current = requestAnimationFrame(paint);
|
||||
},
|
||||
[paint],
|
||||
@@ -267,6 +259,8 @@ export function DiffSurface(props: DiffSurfaceProps) {
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (frameRef.current !== null) cancelAnimationFrame(frameRef.current);
|
||||
// Fast Refresh preserves refs while rerunning effects. Release ownership of the canceled
|
||||
// request so the refreshed renderer can schedule its first paint.
|
||||
frameRef.current = null;
|
||||
},
|
||||
[],
|
||||
|
||||
Reference in New Issue
Block a user