fix: open card link in new tab using target _blank#2299
fix: open card link in new tab using target _blank#2299Tushar8466 wants to merge 6 commits intojson-schema-org:mainfrom
Conversation
|
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! |
There was a problem hiding this comment.
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
Cardcomponent to render its link withtarget="_blank"andrel="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.
| <Link | ||
| href={link} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| data-test="card-link" | ||
| > |
There was a problem hiding this comment.
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.
components/Card.tsx
Outdated
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| data-test="card-link" |
There was a problem hiding this comment.
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.
| target="_blank" | |
| rel="noopener noreferrer" | |
| data-test="card-link" | |
| target='_blank' | |
| rel='noopener noreferrer' | |
| data-test='card-link' |
| <Link | ||
| href={link} | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| data-test="card-link" | ||
| > | ||
| <CardBody link={link} {...props} /> | ||
| </Link> |
There was a problem hiding this comment.
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.
| <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' | ||
| > |
There was a problem hiding this comment.
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.
|
Hi @Tushar8466 |
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
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! |
Utkarsh-123github
left a comment
There was a problem hiding this comment.
Hi @Tushar8466 , on clicking Join Slack button, it is opening in the same tab.
Please fix this whenever you get time.
Thanks !

|
@Utkarsh-123github I have addressed all the requested changes. Here's a summary of what was fixed:
|
|
@Utkarsh-123github I have made the changes you were asking for |
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"andrel="noopener noreferrer"to all external anchortags so they open in a new browser tab without navigating the user away from
the current page.
Checklist
rel="noopener noreferrer"added for security