Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/core/src/viewport/visual-tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -978,4 +978,19 @@ export class VisualTracer {
{ attr: OVERLAY_ATTR },
);
}

/**
* Attaches automatic overlay cleanup on page navigation.
* Call once per page to ensure overlays don't persist across navigations.
* Returns a cleanup function to detach the listener.
*/
attachAutoCleanup(page: Page): () => void {
const handler = () => {
this.clearOverlays(page).catch(() => {});
};
page.on('framenavigated', handler);
return () => {
page.off('framenavigated', handler);
};
}
}