Skip to content

Focus Timer: react to the linked window closing - #416

Merged
AllTerrainDeveloper merged 1 commit into
WordPress:trunkfrom
Alexismlg:fix/focus-timer-window-events
Jul 24, 2026
Merged

Focus Timer: react to the linked window closing#416
AllTerrainDeveloper merged 1 commit into
WordPress:trunkfrom
Alexismlg:fix/focus-timer-window-events

Conversation

@Alexismlg

Copy link
Copy Markdown
Contributor

Fixes #410

Follow-up to #403 (which added the Focus Timer widget) — addresses the review feedback in #410.

Changes

  • The window picker now lists only currently-open windows — a closed window is nothing to shake, so it is never offered as a choice (drops the previous dangling "(closed)" entry).
  • The timer runtime now listens for desktop-mode-window-closed. If the linked window is closed while the timer is running or paused, the timer is cancelled (back to idle) and a toast explains why. The listener lives in the page-wide runtime rather than the view, so it fires even when the widget card has been re-docked or torn down.

Testing

  • npm run typecheck, npm run lint (on the new sources), and npm run build:widget-focus-timer all pass.
  • Verified in wp-env: closing a different window does not affect a running timer; closing the linked window cancels it (→ idle) with a toast; the picker no longer lists closed windows.

Addresses review feedback (WordPress#410):

- The window picker now lists only currently-open windows. A closed
  window is nothing to shake, so it is never offered as a choice (drops
  the previous dangling "(closed)" entry).
- The timer runtime now listens for `desktop-mode-window-closed`. If the
  linked window is closed while the timer is running or paused, the timer
  is cancelled (back to idle) and a toast explains why. The listener
  lives in the page-wide runtime, not the view, so it fires even when the
  widget card has been re-docked or torn down.

@AllTerrainDeveloper AllTerrainDeveloper left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Works as expected!

@AllTerrainDeveloper
AllTerrainDeveloper merged commit 29c8d1e into WordPress:trunk Jul 24, 2026
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.

Pomodoro widget should listen to window events

2 participants