-
Notifications
You must be signed in to change notification settings - Fork 234
Fix #7677: 3.20 Sometimes Global Score doesn't auto-update across tabs #7786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes issue #7677 where global scores don't automatically update across browser tabs. The implementation adds a localStorage-based mechanism to broadcast global score updates between tabs, ensuring score consistency across the entire browser session.
Key changes:
- Added localStorage event broadcasting for global score updates
- Implemented cross-tab synchronization using storage events
- Centralized UI update logic for global score display
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| function updateGlobalScoreUI(newScoreData) { | ||
| // Update local state | ||
| globalScoreData = newScoreData; | ||
|
|
||
| // Update dashboard widget if visible | ||
| if (isOnDashboard()) { | ||
| const $widget = $('#wpr_global_score_widget'); | ||
| if ($widget.length && newScoreData.html) { | ||
| $widget.html(newScoreData.html); | ||
| } | ||
| } | ||
|
|
||
| // Update Rocket Insights table row if visible | ||
| if (isOnRocketInsights() && newScoreData.row_html) { | ||
| updateGlobalScoreRow(newScoreData); | ||
| } | ||
| } |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function duplicates existing UI update logic found elsewhere in the codebase. The dashboard widget update on lines 441-443 is identical to line 528, and the Rocket Insights update on lines 447-448 is identical to line 591. This creates maintainability issues if the update logic needs to change.
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesFootnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 1 out of 4 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@wordpressfan Do we still continue with this PR as we established that it was edgy. |
|
No, let's block it exactly as @Miraeld , and if needed we can validate later and go ahead with the PR |
Description
Fixes #7677
Uses local storage to spread the data to others tabs.
Type of change
Detailed scenario
What was tested
Manual test like the video
How to test
Follow the video in the issue.
Technical description
Documentation
This pull request enhances the way global score updates are handled across browser tabs by introducing a mechanism to broadcast and synchronize score changes using
localStorageevents. This ensures that when the global score is updated in one tab, the change is immediately reflected in all other open tabs, improving consistency and user experience.Global score synchronization improvements:
broadcastGlobalScoreUpdatefunction to send global score updates to other tabs vialocalStorage, including a timestamp to ensure reliable event firing.storageevent that receives global score updates from other tabs and callsupdateGlobalScoreUIto refresh the score display.UI update enhancements:
updateGlobalScoreUIfunction to centralize UI updates for the global score widget and Rocket Insights table row, simplifying score refresh logic.Mandatory Checklist
Code validation
Code style
Unticked items justification
No tests for this.