prismicio / prismic-react

React components and hooks to fetch and present Prismic content
https://prismic.io/docs/technologies/homepage-reactjs
Apache License 2.0
153 stars 40 forks source link

fix(PrismicLink): only set `target="_blank"` when "Open in new tab" is checked #176

Closed angeloashmore closed 1 year ago

angeloashmore commented 1 year ago

Types of changes

Description

This PR changes <PrismicLink> such that target="_blank" is only automatically set when a Link field's "Open in new tab" checkbox is checked.

Before this PR, <PrismicLink> would set target="_blank" when "Open in new tab" was checked or when the URL was external (i.e. started with https://).

Automatically opening external URLs in new windows was originally introduced as a convenience. However, this meant the "Open in new tab" checkbox was ignored in some cases; if the checkbox was purposely unchecked, the link would still open in a new window. This is considered a bug.

rel="noopener noreferrer" will continue to be set automatically if target="_blank" is set.

Fixes #171

Checklist:

🐛

github-actions[bot] commented 1 year ago

size-limit report 📦

Path Size
dist/index.js 5.51 KB (-0.11% 🔽)
dist/index.cjs 9.02 KB (-0.08% 🔽)