Repository navigation
Stats: replace Button with LinkButton for a link - #51561
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Code Coverage SummaryThis 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. 🤷 |
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
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. |
Nikschavan
left a comment
There was a problem hiding this comment.
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)' } ); |
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Thank you, the changes look good. I pushed the two small fixes from my earlier comments in 91372eb.
Proposed changes
Related product discussion/links
Does this pull request change what data or activity we track or use?
Testing instructions