Skip to content

fix: open card link in new tab using target _blank#2299

Open
Tushar8466 wants to merge 6 commits intojson-schema-org:mainfrom
Tushar8466:fix/open-link-in-new-tab
Open

fix: open card link in new tab using target _blank#2299
Tushar8466 wants to merge 6 commits intojson-schema-org:mainfrom
Tushar8466:fix/open-link-in-new-tab

Conversation

@Tushar8466
Copy link
Contributor

@Tushar8466 Tushar8466 commented Mar 1, 2026

Fixes #2290

What kind of change does this PR introduce?
Bug fix — external links were opening in the same tab instead of a new tab.

What does this PR do?
Added target="_blank" and rel="noopener noreferrer" to all external anchor
tags so they open in a new browser tab without navigating the user away from
the current page.

Checklist

  • I have tested the changes locally
  • External links now open in a new tab
  • No existing functionality is broken
  • rel="noopener noreferrer" added for security

Copilot AI review requested due to automatic review settings March 1, 2026 13:54
@Tushar8466 Tushar8466 requested a review from a team as a code owner March 1, 2026 13:54
@github-project-automation github-project-automation bot moved this to Ready to review in PR - Triage Group Mar 1, 2026
@github-actions
Copy link

github-actions bot commented Mar 1, 2026

Hi @Tushar8466! Thanks a lot for your contribution!

I noticed that the following required information is missing or incomplete: issue reference, kind of change description

Please update the PR description to include this information. You can find placeholders in the PR template for these items.

Thanks a lot!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to ensure external links open in a new browser tab (with rel="noopener noreferrer") so users don’t navigate away from the current page.

Changes:

  • Added target="_blank" to a couple of external <a> links on the home page.
  • Updated the shared Card component to render its link with target="_blank" and rel="noopener noreferrer".

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
pages/index.page.tsx Adds target="_blank" to two GitHub discussion links on the home page.
components/Card.tsx Makes all Card links open in a new tab by default and adds rel for security.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +111 to +116
<Link
href={link}
target="_blank"
rel="noopener noreferrer"
data-test="card-link"
>
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

Card now forces every linked card (including internal routes like /learn/...) to open in a new tab via target='_blank'. This changes in-app navigation behavior and conflicts with the PR description (external links only). Consider applying target/rel only for external URLs (e.g., http(s)://) or making this behavior configurable via a prop.

Copilot uses AI. Check for mistakes.
Comment on lines +113 to +115
target="_blank"
rel="noopener noreferrer"
data-test="card-link"
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

This JSX uses double quotes (target="_blank", rel="...", data-test="...") while the repo Prettier config enforces jsxSingleQuote: true. Using single quotes here will avoid formatting churn / potential CI failures.

Suggested change
target="_blank"
rel="noopener noreferrer"
data-test="card-link"
target='_blank'
rel='noopener noreferrer'
data-test='card-link'

Copilot uses AI. Check for mistakes.
Comment on lines +111 to 118
<Link
href={link}
target="_blank"
rel="noopener noreferrer"
data-test="card-link"
>
<CardBody link={link} {...props} />
</Link>
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

There are existing Cypress component tests for Card (e.g., cypress/components/Card.cy.tsx asserts the rendered link). Since this change adds target/rel behavior (and ideally should vary by internal vs external URLs), please add/adjust tests to assert the new attributes and guard against regressions.

Copilot uses AI. Check for mistakes.
Comment on lines 527 to 531
<a
href='https://github.com/orgs/json-schema-org/discussions/35'
rel='noopener noreferrer'
rel='noopener noreferrer' target='_blank'
className='max-w-[300px] w-full text-center rounded border-2 bg-primary hover:bg-blue-700 transition-all duration-300 ease-in-out text-white h-[40px] mb-4 flex items-center justify-center mx-auto dark:border-none'
>
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

PR description says "Added target=_blank ... to all external links", but this file still contains external anchors without target/rel (e.g., the Landscape link at ~lines 240-245). Either update the remaining external links for consistency or narrow the PR description/scope.

Copilot uses AI. Check for mistakes.
@Utkarsh-123github
Copy link
Member

Hi @Tushar8466
Your PR is having conflicts, please resolve those.
Thanks!

@github-actions
Copy link

github-actions bot commented Mar 1, 2026

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
website ✅ Ready (View Log) Visit Preview 0584212

@codecov
Copy link

codecov bot commented Mar 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4bd72bb) to head (0584212).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #2299   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           30        30           
  Lines          672       672           
  Branches       211       211           
=========================================
  Hits           672       672           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Tushar8466
Copy link
Contributor Author

Hi @Utkarsh-123github, I've successfully resolved all the merge conflicts. The branch is now clean and ready for your review. Please take a look when you get a chance!

Copy link
Member

@Utkarsh-123github Utkarsh-123github left a comment

Choose a reason for hiding this comment

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

Hi @Tushar8466 , on clicking Join Slack button, it is opening in the same tab.
Please fix this whenever you get time.
Thanks !
Image

@github-project-automation github-project-automation bot moved this from Ready to review to Changes requested in PR - Triage Group Mar 3, 2026
@Tushar8466
Copy link
Contributor Author

@Utkarsh-123github I have addressed all the requested changes. Here's a summary of what was fixed:

  • ✅ Added rel="noreferrer" to the target="_blank" anchor tag to resolve the security vulnerability
  • ✅ Fixed the Prettier formatting issue on line 414 to meet the project's code style standards
  • ✅ Build and lint checks are now passing successfully

@Tushar8466
Copy link
Contributor Author

@Utkarsh-123github I have made the changes you were asking for

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

Labels

None yet

Projects

Status: Changes requested

Development

Successfully merging this pull request may close these issues.

🐛 Bug: External links open in the same tab instead of a new tab

3 participants