CBHSQ / findtreatment

FindTreatment.gov, An 18F+SAMHSA Collaboration
https://findtreatment.gov/
Other
19 stars 12 forks source link

Universally control whether external links open in a new tab, defaults to TRUE #500

Closed davemcorwin closed 5 years ago

davemcorwin commented 5 years ago

Resolves #494

This provides a one stop shop for controlling whether our external (or outbound) links open in a new tab. The current default is set to true. Email (email:) and telephone (tel:) links are excluded and will not receive the attributes to open in a new tab.

This just wraps the existing OutboundLink component provided by Google Analytics so that functionality should remain unchanged.

Also adds rel="nooponer noreferrer" attribute to the link.

allisonnorman commented 5 years ago

I noticed that the external links within the content sections aren't set up as outbound links, so they aren't controlled by this change.

I started to try to make the changes to convert them to outbound links. For example, converting an a tag to:

<OutboundLink
   to="https://www.healthcare.gov/income-and-household-information/income/"
   eventLabel="Healthcare.gov link from content"
   aria-label="Link to healthcare.gov"
>
   healthcare.gov
</OutboundLink>
. )

but am getting the following error:

./src/utils/content.js
  Line 595:16:  'OutboundLink' is not defined  react/jsx-no-undef

I'm sure I'm missing something but if you can explain it, @davemcorwin, I can convert the existing link tags to outbound links and push it to this branch. Looks great everywhere else!

allisonnorman commented 5 years ago

Nevermind, I figured it out and learned something (yay!). Created a PR against this branch for your review, @davemcorwin: #504