Skip to content

fix(highlighter): clean up stale rough-notation instances on prop changes#929

Merged
Yeom-JinHo merged 1 commit intomagicuidesign:mainfrom
Yeom-JinHo:fix/highlighter
Mar 19, 2026
Merged

fix(highlighter): clean up stale rough-notation instances on prop changes#929
Yeom-JinHo merged 1 commit intomagicuidesign:mainfrom
Yeom-JinHo:fix/highlighter

Conversation

@Yeom-JinHo
Copy link
Copy Markdown
Member

Description

This PR fixes the Highlighter bug reported in #836 where changing the annotation color could leave the previous rough-notation markup in the DOM, causing multiple highlights to stack.

The Highlighter lifecycle now cleans up the exact annotation instance created by each render, and the annotation setup runs in a layout effect so stale markup is removed before repaint. The related registry artifacts were also regenerated to keep the published output in sync.

Fixes #836.

Changes

  • Switched the Highlighter lifecycle from useEffect to useLayoutEffect.
  • Replaced shared ref-based cleanup with effect-local annotation cleanup so each render removes its own rough-notation instance reliably.
  • Kept the existing ResizeObserver behavior while binding it only to the current annotation instance.
  • Regenerated the registry output files for the updated Highlighter implementation.
  • Verified the change with pnpm --filter=www typecheck and pnpm --filter=www build:registry.

Motivation

When the Highlighter color changed, especially during theme updates, the previous annotation was not always cleaned up before a new one was drawn. This resulted in duplicated highlight strokes and inconsistent visual output.

This change makes the cleanup deterministic and prevents stale annotations from remaining in the DOM across prop updates.

Breaking Changes

None.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 19, 2026

@Yeom-JinHo is attempting to deploy a commit to the product-studio Team on Vercel.

A member of the Team first needs to authorize it.

@Yeom-JinHo Yeom-JinHo self-assigned this Mar 19, 2026
@Yeom-JinHo Yeom-JinHo merged commit a4e6e4d into magicuidesign:main Mar 19, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: text highlighter was drawn multiple times when color change

1 participant