Skip to content

Conversation

@jimmymadon
Copy link
Collaborator

Summary

Addresses issue:

Relevant technical choices

PR Author Checklist

  • My code is tested and passes existing unit tests.
  • My code has an appropriate set of unit tests which all pass.
  • My code is backward-compatible with WordPress 5.2 and PHP 7.4.
  • My code follows the WordPress coding standards.
  • My code has proper inline documentation.
  • I have added a QA Brief on the issue linked above.
  • I have signed the Contributor License Agreement (see https://cla.developers.google.com/).

Do not alter or remove anything below. The following sections will be managed by moderators only.

Code Reviewer Checklist

  • Run the code.
  • Ensure the acceptance criteria are satisfied.
  • Reassess the implementation with the IB.
  • Ensure no unrelated changes are included.
  • Ensure CI checks pass.
  • Check Storybook where applicable.
  • Ensure there is a QA Brief.
  • Ensure there are no unexpected significant changes to file sizes.

Merge Reviewer Checklist

  • Ensure the PR has the correct target branch.
  • Double-check that the PR is okay to be merged.
  • Ensure the corresponding issue has a ZenHub release assigned.
  • Add a changelog message to the issue.

@github-actions
Copy link

Storybook is ready:

@github-actions
Copy link

github-actions bot commented Oct 29, 2025

Build files for 1daeb60 are ready:

@github-actions
Copy link

github-actions bot commented Oct 29, 2025

Size Change: +1.08 kB (+0.05%)

Total Size: 2.19 MB

ℹ️ View Unchanged
Filename Size Change
./dist/assets/blocks/reader-revenue-manager/block-editor-plugin/editor-styles.css 124 B 0 B
./dist/assets/blocks/reader-revenue-manager/block-editor-plugin/editor-styles.js 20 B 0 B
./dist/assets/blocks/reader-revenue-manager/block-editor-plugin/index.js 42.7 kB 0 B
./dist/assets/blocks/reader-revenue-manager/common/editor-styles.css 307 B 0 B
./dist/assets/blocks/reader-revenue-manager/common/editor-styles.js 20 B 0 B
./dist/assets/blocks/reader-revenue-manager/contribute-with-google/index.js 5.88 kB 0 B
./dist/assets/blocks/reader-revenue-manager/contribute-with-google/non-site-kit-user.js 5.07 kB 0 B
./dist/assets/blocks/reader-revenue-manager/subscribe-with-google/index.js 5.88 kB 0 B
./dist/assets/blocks/reader-revenue-manager/subscribe-with-google/non-site-kit-user.js 5.07 kB 0 B
./dist/assets/blocks/sign-in-with-google/editor-styles.css 84 B 0 B
./dist/assets/blocks/sign-in-with-google/editor-styles.js 20 B 0 B
./dist/assets/blocks/sign-in-with-google/index.js 18.6 kB 0 B
./dist/assets/css/googlesitekit-admin-css-********************.min.css 64.5 kB +6 B (+0.01%)
./dist/assets/css/googlesitekit-adminbar-css-********************.min.css 11.7 kB 0 B
./dist/assets/css/googlesitekit-authorize-application-css-********************.min.css 846 B 0 B
./dist/assets/css/googlesitekit-wp-dashboard-css-********************.min.css 8.57 kB 0 B
./dist/assets/js/146-********************.js 963 B 0 B
./dist/assets/js/201-********************.js 2.85 kB 0 B
./dist/assets/js/314-********************.js 100 kB 0 B
./dist/assets/js/315-********************.js 3.08 kB 0 B
./dist/assets/js/379-********************.js 3.7 kB 0 B
./dist/assets/js/590-********************.js 1.89 kB 0 B
./dist/assets/js/640-********************.js 2.36 kB 0 B
./dist/assets/js/909-********************.js 1.01 kB 0 B
./dist/assets/js/analytics-advanced-tracking-********************.js 475 B 0 B
./dist/assets/js/googlesitekit-activation-********************.js 24.1 kB +45 B (+0.19%)
./dist/assets/js/googlesitekit-ad-blocking-recovery-********************.js 54.9 kB +59 B (+0.11%)
./dist/assets/js/googlesitekit-adminbar-********************.js 34.4 kB +50 B (+0.15%)
./dist/assets/js/googlesitekit-api-********************.js 7.79 kB 0 B
./dist/assets/js/googlesitekit-block-tracking-********************.js 5.51 kB 0 B
./dist/assets/js/googlesitekit-components-********************.js 5.74 kB 0 B
./dist/assets/js/googlesitekit-consent-mode-********************.js 25.5 kB 0 B
./dist/assets/js/googlesitekit-data-********************.js 1.7 kB 0 B
./dist/assets/js/googlesitekit-datastore-forms-********************.js 6.99 kB 0 B
./dist/assets/js/googlesitekit-datastore-location-********************.js 1.51 kB 0 B
./dist/assets/js/googlesitekit-datastore-site-********************.js 17.3 kB 0 B
./dist/assets/js/googlesitekit-datastore-ui-********************.js 7.11 kB 0 B
./dist/assets/js/googlesitekit-datastore-user-********************.js 22.8 kB 0 B
./dist/assets/js/googlesitekit-entity-dashboard-********************.js 61.8 kB +58 B (+0.09%)
./dist/assets/js/googlesitekit-events-provider-contact-form-7-********************.js 1.77 kB 0 B
./dist/assets/js/googlesitekit-events-provider-easy-digital-downloads-********************.js 745 B 0 B
./dist/assets/js/googlesitekit-events-provider-mailchimp-********************.js 1.77 kB 0 B
./dist/assets/js/googlesitekit-events-provider-ninja-forms-********************.js 1.69 kB 0 B
./dist/assets/js/googlesitekit-events-provider-optin-monster-********************.js 1.72 kB 0 B
./dist/assets/js/googlesitekit-events-provider-popup-maker-********************.js 1.79 kB 0 B
./dist/assets/js/googlesitekit-events-provider-woocommerce-********************.js 1.13 kB 0 B
./dist/assets/js/googlesitekit-events-provider-wpforms-********************.js 1.77 kB 0 B
./dist/assets/js/googlesitekit-i18n-********************.js 6.16 kB 0 B
./dist/assets/js/googlesitekit-key-metrics-setup-********************.js 46.5 kB +68 B (+0.15%)
./dist/assets/js/googlesitekit-main-dashboard-********************.js 135 kB +47 B (+0.03%)
./dist/assets/js/googlesitekit-metric-selection-********************.js 52.7 kB +80 B (+0.15%)
./dist/assets/js/googlesitekit-modules-ads-********************.js 47.6 kB +48 B (+0.1%)
./dist/assets/js/googlesitekit-modules-adsense-********************.js 123 kB +62 B (+0.05%)
./dist/assets/js/googlesitekit-modules-analytics-4-********************.js 189 kB +45 B (+0.02%)
./dist/assets/js/googlesitekit-modules-********************.js 19.9 kB -3 B (-0.02%)
./dist/assets/js/googlesitekit-modules-pagespeed-insights-********************.js 23.5 kB 0 B
./dist/assets/js/googlesitekit-modules-reader-revenue-manager-********************.js 43.6 kB +53 B (+0.12%)
./dist/assets/js/googlesitekit-modules-search-console-********************.js 65.3 kB +70 B (+0.11%)
./dist/assets/js/googlesitekit-modules-sign-in-with-google-********************.js 34.4 kB +40 B (+0.12%)
./dist/assets/js/googlesitekit-modules-tagmanager-********************.js 30 kB +1 B (0%)
./dist/assets/js/googlesitekit-notifications-********************.js 66.6 kB +48 B (+0.07%)
./dist/assets/js/googlesitekit-polyfills-********************.js 230 B 0 B
./dist/assets/js/googlesitekit-settings-********************.js 124 kB +64 B (+0.05%)
./dist/assets/js/googlesitekit-splash-********************.js 73.3 kB +64 B (+0.09%)
./dist/assets/js/googlesitekit-user-input-********************.js 46 kB +59 B (+0.13%)
./dist/assets/js/googlesitekit-vendor-********************.js 322 kB 0 B
./dist/assets/js/googlesitekit-widgets-********************.js 104 kB +46 B (+0.04%)
./dist/assets/js/googlesitekit-wp-dashboard-********************.js 60 kB +67 B (+0.11%)
./dist/assets/js/runtime-********************.js 1.93 kB 0 B

compressed-size-action

Copy link
Collaborator

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

I know it's not part of this issue, but we might as well fix the Reader Revenue ad blocker notification not having an external "Learn more" link while we're at it 🤔

image

More generally though: this is a roundabout way of handling the already-server-supplied target prop and overloading its meaning. I wouldn't expect marking something to open in a new window to be the same as an external link, nor the inverse. But now: I have to say "anything in a new window is external", even though that might not be the case.

And, though it's less likely: we can't mark anything as external but keep it opening in the same tab.

I think the IB here isn't the right approach; we should be adding an external prop from the server notifications and using both it and the target prop to set the CTAButton's props accordingly.

isSaving={ inProgress }
onClick={ onClick }
href={ href }
target={ external ? '_blank' : '_self' }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why explicitly specify target="_self" here? We can just do undefined if the link isn't external and the attribute will be omitted entirely, which is arguably better.

Suggested change
target={ external ? '_blank' : '_self' }
target={ external ? '_blank' : undefined }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@tofumatt This currently follows the exact pattern introduced in the other similar assets/js/components/Notice/CTAButton.js component. So I wouldn't want to deviate for the exact same logic - and if we do, perhaps we should change this in both places. But this feels too minor to warrant additional testing, etc? Same for the comment below.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, let's change it in both places then. There's no reason to specify target="_self", so let's change it as part of this PR.

It will result in snapshots needing updating but the behaviour is the same, so let's just remove the extra (unneeded) code here so we don't continue with the target="_self" code 😄

onClick,
href,
external,
hideExternalIndicator,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is undefined by default, but we should be a bit more explicit and mark this as false by default.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same as above. 🙂

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's update it in both places then, those kinds of small improvements are fine to make as a result of code review here 🙂

@jimmymadon
Copy link
Collaborator Author

@tofumatt Thanks for raising these points!

I wouldn't expect marking something to open in a new window to be the same as an external link, nor the inverse.

I believe this is a pattern followed throughout Site Kit:
All external links always open in a new tab which prevents users navigating away from Site Kit.
Inversely, only external links are opened in a new tab - there are no internal Site Kit links within the plugin that open in a separate tab to prevent the user deliberately having the plugin open in multiple tabs. I think this is evident in many places like:

if ( type === EXTERNAL_LINK ) {
labelSuffix = _x(
'(opens in a new tab)',

So if we do think otherwise, we would have to be consistent with our definitions across the plugin.

Copy link
Collaborator

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

I understand that an external link will always open in a new window, and that is actually a fair rule to implement. I think it's expected, as well, that marking something as external will always result in the link's behaviour changing.

What I don't think is a reasonable expectation is that marking any link as needing to open in a new window means it's a link external to Site Kit. Even if that's currently always the case, it's not intuitive that specifying target="_blank" on a button will mean that button is external to Site Kit and should be marking as such.

I don't think that's the API we should be building—but I do understand that the issue here is we are dealing with a notifications API on the Proxy/Service that we would need to change.

Ultimately I think the appropriate thing to do is to surface this "overloading" on the ctaTarget attribute in as few places as possible and actually to have the notifications API on the Service send better data down, but I'm not entirely convinced that part is worth the effort.

I think it's worth documenting this in the code but we don't need to add prop names.

Let's clean up some of the undefined vs false code and the target="_self" stuff though; we don't need to re-implement things that aren't explicit/optimal if we can straightforwardly refactor them in this PR. 🙂

@jimmymadon
Copy link
Collaborator Author

I know it's not part of this issue, but we might as well fix the Reader Revenue ad blocker notification not having an external "Learn more" link while we're at it

I forgot to reply to this in my last round - but this does seem to have an external link. I'm not sure which component the screenshot you've pasted is referring to.

@jimmymadon
Copy link
Collaborator Author

@tofumatt The 3 VRT failures here are related to charts not loading and hence are irrelevant to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants