Skip to content

fix(page-practice): debounce blur to prevent ad refresh resetting lesson#576

Open
faneb wants to merge 3 commits into
aradzie:masterfrom
faneb:fix/ad-refresh-resets-lesson
Open

fix(page-practice): debounce blur to prevent ad refresh resetting lesson#576
faneb wants to merge 3 commits into
aradzie:masterfrom
faneb:fix/ad-refresh-resets-lesson

Conversation

@faneb

@faneb faneb commented Mar 6, 2026

Copy link
Copy Markdown

Summary

Fixes #168 — third-party ad scripts briefly steal and return focus, which triggers handleBluronResetLesson(), resetting the lesson mid-session.

  • Debounce blur handling: handleBlur now delays the lesson reset by 300 ms. If focus returns within that window (as it does during an ad refresh), handleFocus cancels the pending timer and the lesson continues uninterrupted.
  • Clear orphaned timers: handleBlur clears any existing timer before starting a new one, preventing multiple queued resets if blur fires rapidly. Timer is also cleaned up in componentWillUnmount.
  • Add regression test: Renders the full PracticeScreen, simulates a transient blur/re-focus cycle, and asserts the lesson text is preserved.

@semanticdiff-com

semanticdiff-com Bot commented Mar 6, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  packages/page-practice/lib/practice/Presenter.tsx  21% smaller
  packages/page-practice/lib/practice/Presenter.test.tsx  0% smaller

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.

Advertisement resets causes enter/start to reset

1 participant