-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idea: make it easier to create links that open in new windows #360
Comments
Yeah, this is probably worthwhile. Teaching Vacancies defined a custom helper for this a while back. I'd imagine other teams have defined similar helpers too, so I think there is value in extracting something out into this gem. |
That looks perfect, thanks @cpjmcquillan! Definitely feels like a separate method is the way to go, rather than adding more args to CTRL + c → CTRL + v |
I like this idea, but I think we should avoid using the word I think the most developer-friendly thing to do would be an additional keyword argument on the existing helper. So perhaps something like this: <%= govuk_link_to "privacy policy", privacy_policy_path, new_tab: true %> We could also allow a string to be set instead of a boolean, for cases where you might want to rewrite the additional text shown (eg if translating into another language): <%= govuk_link_to "privacy policy", privacy_policy_path, new_tab: "(opens in new tab)" %> (An empty string could be set if you really don’t want to include any additional text) |
Sounds like a sensible approach @frankieroberto -
|
According to the design system, links that open in new tabs/windows need to:
target: "_blank"
rel: "noreferrer noopener"
(to prevent reverse tabnabbing)(opens in new tab)
or similarRather than having to remember all of these things every time, we could bake the functionality into the library. It could be implemented as:
#govuk_external_link_to
#govuk_link_to
and friends - maybeexternal: true
The text appended to the end should be
nil
by default (leaving it to the dev) but can be defaulted so it always adds the(link opens in new tab)
suffix - unless supressed withexternal_text: nil
or similar.The text was updated successfully, but these errors were encountered: