Skip to content

Stats: replace Button with LinkButton for a link - #51561

Merged
Nikschavan merged 5 commits into
trunkfrom
update/stats-link-button
Aug 26, 2026
Merged

Nikschavan merged 5 commits into
trunkfrom
update/stats-link-button

Conversation

@simison

@simison simison commented Aug 25, 2026

Copy link
Copy Markdown
Member

Proposed changes

  • Replaces workaround of using Button for links with appropiate new LinkButton component.

Related product discussion/links

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

Testing instructions

  • Test "View page/post" button
  • No visual/functional changes

@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the update/stats-link-button branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack update/stats-link-button
bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/stats-link-button

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@jp-launch-control

jp-launch-control Bot commented Aug 25, 2026 •

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 · JS report

@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!


Premium Analytics plugin:

No scheduled milestone found for this plugin.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@simison simison added the Reviewer Can Merge PR author indicates the reviewer is free to merge/deploy if they want to own the change. label Aug 25, 2026

@Nikschavan Nikschavan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, this reads well and it closes the loop on the :any-link workaround from #50891. Two small things inline: the two "omits the action" tests no longer match the new accessible name, and the styles.viewPost class no longer exists.


const action = screen.getByRole( 'link', { name: 'View post' } );
// `openInNewTab` appends a screen-reader hint to the accessible name.
const action = screen.getByRole( 'link', { name: 'View post(opens in a new tab)' } );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since the accessible name now ends in "(opens in a new tab)", the /^View (post|page)$/ regex in the two "omits the action" tests below (lines 216 and 224) can no longer match a rendered link, so they pass even if safeHttpUrl is removed. Dropping the $ anchor keeps both tests meaningful.

size="compact"
nativeButton={ false }
role="link"
className={ styles.viewPost }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The .viewPost rule was the one removed from the stylesheet, so styles.viewPost is undefined now and this prop does nothing.

The accessible name now ends in '(opens in a new tab)', so the anchored regex in the two 'omits the action' tests could never match a rendered link. Drop the end anchor so they fail again when the URL guard is removed. The viewPost class was deleted with the any-link workaround, so the className prop resolved to undefined.

@Nikschavan Nikschavan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, the changes look good. I pushed the two small fixes from my earlier comments in 91372eb.

@Nikschavan
Nikschavan merged commit 4d0ffe0 into trunk Aug 26, 2026
90 of 91 checks passed
@Nikschavan
Nikschavan deleted the update/stats-link-button branch August 26, 2026 02:04
@github-actions github-actions Bot removed the [Status] Needs Review This PR is ready for review. label Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Premium Analytics [Plugin] Premium Analytics Reviewer Can Merge PR author indicates the reviewer is free to merge/deploy if they want to own the change. [Type] Janitorial

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants