Skip to content

v0.13.5-pl.6

Choose a tag to compare

@TBarregren TBarregren released this 13 May 19:37
· 49 commits to main since this release

Bug fix: Elevation chart no longer disappears in the Gutenberg editor when a webfont finishes loading after the block has mounted.

Symptom (pre-fix)

In the Gutenberg editor, the GPX Elevation chart would render briefly (< 1 second) after the block loaded and then vanish, leaving only the wrapper background visible. No console errors, no warning placeholder. The frontend was unaffected. Whether a user saw the bug depended on the editor iframe's font-cache state: cached fonts never triggered the bad code path, so the chart stayed visible on subsequent loads.

Root cause

chart.tsx's loadingdone listener tried to retrigger the margin computation by clearing margins to null and re-asserting fontsReady. Two compounding issues defeated the intent:

  1. setFontsReady( true ) was a no-op whenever fontsReady was already true — React bails out on identical state.
  2. setMargins( null ) did cause a re-render, but margins was not in the layout effect's dep list, so the effect stayed dormant after the clear.

Net effect: the first loadingdone event after the initial measurement permanently emptied the chart.

Fix

Route the re-measure request through a dedicated remeasureToken counter that is in the layout effect's dep list. The next layout-effect tick recomputes margins under the final font metrics and overwrites them in the same commit, so the chart never has a "blank" intermediate frame.

Regression-pinned by a new test in chart.test.tsx that installs a minimal document.fonts stub, mounts the chart, fires loadingdone, and asserts both axis lines remain in the DOM afterwards.

Origin

The bug was introduced in v0.13.5-pl.1 when the loadingdone listener was first added as part of the tick-label typography wiring, but it surfaced more reliably from v0.13.5-pl.4 onwards because pl.4's Map editor preview changes shifted the editor iframe's webfont load timing in a way that frequently pushed loadingdone past the Elevation chart's initial mount.