Skip to content

Fix: Prevent "Powered by Ghost" from opening two tabs#24623

Merged
9larsons merged 5 commits into
TryGhost:mainfrom
niranjan-uma-shankar:fix-powered-by-click
Jun 8, 2026
Merged

Fix: Prevent "Powered by Ghost" from opening two tabs#24623
9larsons merged 5 commits into
TryGhost:mainfrom
niranjan-uma-shankar:fix-powered-by-click

Conversation

@niranjan-uma-shankar

@niranjan-uma-shankar niranjan-uma-shankar commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

Summary

In Portal, clicking on "Powered by Ghost", in the overlay that appears in the signup modal, opens ghost.org in two tabs. Example:

Screen.Recording.2025-08-07.at.7.40.18.PM.mov

Root cause:

  • The element contains both a href attribute and an onClick handler, leading to two tabs for a single click.

Fix

  • Remove the redundant onClick handler.

Testing Instructions

  • Visit http://localhost:2368/ and click on the "Subscribe" button in the header.
  • In the modal overlay, click on "Powered by Ghost" and verify that it opens ghost.org in a single new tab.
  • Run the test (verify that node version is >22):
cd apps/portal && yarn test portal-links.test.js 

This change ensures that clicking on the Powered By link does not open two tabs.
@coderabbitai

coderabbitai Bot commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Removed the custom onClick handler from the anchor in apps/portal/src/components/common/PoweredBy.js that previously called window.open('https://ghost.org', '_blank'). The anchor now relies on href="https://ghost.org" with target="_blank" and rel="noopener noreferrer" and includes a data-test-powered-by attribute. Added a test in apps/portal/src/tests/portal-links.test.js that renders the portal signup, finds the "powered by ghost" link in the popup, and asserts href, target, rel, and absence of an onClick handler. No other component structure, content, or exports changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0906e2 and 16dbde3.

📒 Files selected for processing (1)
  • apps/portal/src/components/common/PoweredBy.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/portal/src/components/common/PoweredBy.js
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@niranjan-uma-shankar niranjan-uma-shankar changed the title Removed redundant onClick handler from Powered By Portal component Fix: Prevent "Powered by Ghost" from opening two tabs Aug 7, 2025
@niranjan-uma-shankar niranjan-uma-shankar marked this pull request as ready for review August 11, 2025 13:27

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/portal/src/components/common/PoweredBy.js (1)

14-14: Accessibility: hide decorative SVG from screen readers.

Mark the logo as decorative so the link’s accessible name is just “Powered by Ghost.”

-                <GhostLogo />
+                <GhostLogo aria-hidden="true" focusable="false" />
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 888ae06 and f2844e3.

📒 Files selected for processing (1)
  • apps/portal/src/components/common/PoweredBy.js (1 hunks)
🔇 Additional comments (1)
apps/portal/src/components/common/PoweredBy.js (1)

13-16: Fix looks good: removes double navigation and keeps tabnabbing protections.

Relying on the anchor’s default behavior with target="_blank" and rel="noopener noreferrer" resolves the two-tab issue and preserves security best practices.

Comment thread apps/portal/src/components/common/PoweredBy.js
Adds a data-test-powered-by attribute to the external link to simplify E2E targeting.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/portal/src/tests/portal-links.test.js (2)

362-362: Make the rel assertion order-insensitive.

Avoid brittleness if token order changes. Assert both tokens are present.

-            expect(poweredByLink).toHaveAttribute('rel', 'noopener noreferrer');
+            const rel = poweredByLink.getAttribute('rel') || '';
+            expect(rel).toContain('noopener');
+            expect(rel).toContain('noreferrer');

357-357: Prefer findByRole for async rendering in iframe.

Using findByRole reduces flakiness if the link renders slightly after the iframe is ready.

-            const poweredByLink = within(popupFrame.contentDocument).getByRole('link', {name: /powered by ghost/i});
+            const poweredByLink = await within(popupFrame.contentDocument).findByRole('link', {name: /powered by ghost/i});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f2844e3 and f0906e2.

📒 Files selected for processing (1)
  • apps/portal/src/tests/portal-links.test.js (1 hunks)
🔇 Additional comments (1)
apps/portal/src/tests/portal-links.test.js (1)

347-355: Good coverage of the PoweredBy link semantics.

Asserting presence, href, target, and rel on the link is solid and aligns with the fix.

Comment thread apps/portal/src/tests/portal-links.test.js Outdated
@ErisDS ErisDS added the community [triage] Community features and bugs label Sep 17, 2025
@9larsons 9larsons force-pushed the fix-powered-by-click branch from 120d132 to 9bb8bdc Compare June 8, 2026 19:08
@9larsons 9larsons force-pushed the fix-powered-by-click branch from 9bb8bdc to 21af29b Compare June 8, 2026 19:28
@9larsons

9larsons commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@niranjan-uma-shankar Sorry for the delay and the commit noise - the rebase was a bit messy. Thanks for the submission!

@9larsons 9larsons enabled auto-merge (squash) June 8, 2026 19:30
@9larsons 9larsons disabled auto-merge June 8, 2026 19:30
@9larsons 9larsons enabled auto-merge (squash) June 8, 2026 19:31
@9larsons 9larsons disabled auto-merge June 8, 2026 19:35
@9larsons 9larsons merged commit 677928e into TryGhost:main Jun 8, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community [triage] Community features and bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants