Skip to content

fix: preserve focus across heartbeat re-renders in dashboard widgets - #271

Merged
josephfusco merged 5 commits into
WordPress:mainfrom
i-am-chitti:heartbeat-265
Aug 12, 2026
Merged

josephfusco merged 5 commits into
WordPress:mainfrom
i-am-chitti:heartbeat-265

Conversation

@i-am-chitti

Copy link
Copy Markdown
Collaborator

Description

  • Capture focus before container.html() swaps in Active Posts and Who's Online, restore it after - falling back to the container if the focused item no longer exists.
  • Add data-post-id to Active Posts rows (Who's Online already had data-user-id); both containers get tabindex="-1" as the fallback focus target.
  • Add e2e coverage for focus preservation across a heartbeat re-render in both widgets.

Fixes #265.

Test plan

  • npx playwright test --config tests/e2e/playwright.config.js tests/e2e/presence-widgets.test.js

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Investigating the focus-loss cause and writing the e2e tests

@github-actions

Copy link
Copy Markdown
Contributor

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props iamchitti, joefusco.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown
Contributor

▶ Preview in WordPress Playground

Open in WordPress Playground

Boots a fresh WordPress with this PR's presence-api build, seeds 5 demo users, and drops you on the dashboard.

Stress-test variant: 40 demo users · Built from 8fdedf8787aa11f0ed7a06282c9c75337523ca81. Auto-updates when you push.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.87%. Comparing base (e438faa) to head (8fdedf8).

❌ Your patch check has failed because the patch coverage (50.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #271   +/-   ##
=========================================
  Coverage     75.87%   75.87%           
  Complexity      176      176           
=========================================
  Files            14       14           
  Lines          1832     1832           
=========================================
  Hits           1390     1390           
  Misses          442      442           
Flag Coverage Δ
multisite 75.87% <50.00%> (ø)
phpunit 74.56% <50.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@josephfusco josephfusco 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.

Nice work!

@josephfusco
josephfusco merged commit 8310ba7 into WordPress:main Aug 12, 2026
18 checks passed
@josephfusco josephfusco added the [Area] Widgets Issues for the dashboard widgets label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Widgets Issues for the dashboard widgets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Heartbeat swap drops focus to <body> in dashboard widgets

2 participants