Skip to content

Premium Analytics: fix widgets resizing when a dropdown opens - #50624

Merged
louwie17 merged 1 commit into
trunkfrom
wooa7s-1763-metrics-dropdown-affects-other-widget-dimensions
Jul 17, 2026
Merged

Premium Analytics: fix widgets resizing when a dropdown opens#50624
louwie17 merged 1 commit into
trunkfrom
wooa7s-1763-metrics-dropdown-affects-other-widget-dimensions

Conversation

@louwie17

Copy link
Copy Markdown
Contributor

Proposed changes

Opening the Metrics dropdown on the analytics dashboard resized other widgets: the Most viewed widget shifted down while the dropdown was open and snapped back on close.

Both the Most viewed (top-posts) and Referrers widgets carried a widget-picker workaround at the bottom of their CSS module:

:global([inert]:not([inert="true"])) .root {
	height: auto;
	aspect-ratio: 4 / 3;
	overflow: hidden;
}

Those are exactly the three declarations seen appearing on click in the reported DevTools screenshot.

The flaw is that the rule keys "am I in the widget-picker preview?" off a global [inert] ancestor selector, but inert isn't owned by the picker. A modal popup — such as the Metrics SelectControl — inerts background content while it is open, so a sibling widget matches this selector and takes on a 4:3 aspect ratio for as long as the dropdown stays open.

This hack is already obsolete. #50294 removed it from the other 17 widgets and deleted the AGENTS.md guidance recommending it, because the picker host now sizes preview tiles itself. These two widgets merged after that cleanup (Jul 9 and Jul 14) from branches cut before it, quietly reintroducing the rule. This PR removes both, restoring parity with the rest of the package.

The [inert] image-sizing rules elsewhere (avatars, flags) are deliberately left alone — they only restore intended sizes, so they are no-ops outside the picker.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

Reproducing the bug (on trunk)

  • Go to Jetpack → Premium Analytics.
  • Make sure both the Traffic and Most viewed widgets are on the dashboard, with Traffic narrow enough that its metric picker renders as a dropdown rather than tabs (resize it small — the dropdown only appears below metrics.length * MIN_TAB_WIDTH).
  • Open the Traffic widget's Metrics dropdown.
  • 🐞 The Most viewed widget shifts downward / changes height while the dropdown is open, and returns when it closes.

Verifying the fix (on this branch)

  • Repeat the steps above — opening the Metrics dropdown should leave every other widget's dimensions untouched.
  • Repeat with the Referrers widget on the dashboard; it should also stay put.

Checking for regressions in the widget picker (this is what the removed rule was originally for)

🤖 Generated with Claude Code

https://claude.ai/code/session_011oGxxfSNdnj1Pyf5FRnPQC

The Most viewed and Referrers widgets each carried a widget-picker
workaround keyed off a global `[inert]` ancestor selector:

    :global([inert]:not([inert="true"])) .root {
        height: auto;
        aspect-ratio: 4 / 3;
        overflow: hidden;
    }

`inert` is not owned by the picker. A modal popup — such as the Metrics
SelectControl — inerts background content while open, so the sibling
widget matched this selector and took on a 4:3 aspect ratio for as long
as the dropdown stayed open, then snapped back on close.

#50294 already removed this hack from the other 17 widgets, along with
the AGENTS.md guidance recommending it, since the picker host now sizes
preview tiles itself. These two widgets merged after that cleanup from
branches cut before it, reintroducing the rule. Remove both to restore
parity with the rest of the package.

Fixes WOOA7S-1763.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011oGxxfSNdnj1Pyf5FRnPQC
@louwie17
louwie17 requested review from a team as code owners July 17, 2026 11:58
@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report

@retrofox retrofox left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • 🔴 Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jul 17, 2026
@louwie17
louwie17 merged commit a80f0cd into trunk Jul 17, 2026
74 checks passed
@louwie17
louwie17 deleted the wooa7s-1763-metrics-dropdown-affects-other-widget-dimensions branch July 17, 2026 12:07
@github-actions github-actions Bot removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants