Skip to content
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

Prevent creating <a> without href in header service name #1826

Closed
2 tasks
hannalaakso opened this issue Jun 3, 2020 · 7 comments · Fixed by #2617
Closed
2 tasks

Prevent creating <a> without href in header service name #1826

hannalaakso opened this issue Jun 3, 2020 · 7 comments · Fixed by #2617
Assignees
Labels
header 🕔 hours A well understood issue which we expect to take less than a day to resolve. nunjucks
Milestone

Comments

@hannalaakso
Copy link
Member

hannalaakso commented Jun 3, 2020

What

As discussed in #1825, serviceName has an implicit dependency on serviceUrl. If serviceName is set but serviceUrl isn't, the macro renders an <a> tag without href.

If serviceName is set, we could:

  • Check if serviceUrl is set and if it's not, render a <span> in place of <a> OR have a default value / for href
  • Improve the macro docs around this to make the dependency explicit.

Why

To help our users to avoid outputting invalid markup / miss including the href.

Who needs to know about this

Devs, Mark?

Done when

  • It's not possible to output an <a> tag without href for service name using the macro
  • We've improved the macro documentation to make the dependency clearer
@andymantell
Copy link
Contributor

I'd be quite happy to pick this up following on from #1825 if you know which way you want to go. I'd probably be inclined to go for the <span> when the serviceUrl isn't present for flexibility - but I don't know whether you may want to discourage that as an option in the name of consistency? I.e. when a service name is present, it is always a link. But perhaps the documentation would be sufficient to encourage people to set a serviceUrl

As for making serviceUrl have a default value of / - this would be a breaking change I think? Anyone who's currently using the header without a serviceUrl will merrily be rendering an <a> with no href. Adding a / would change their output more significantly than rendering a <span>.

@kellylee-gds kellylee-gds added 🕔 hours A well understood issue which we expect to take less than a day to resolve. and removed awaiting triage Needs triaging by team labels Jun 8, 2020
@hannalaakso
Copy link
Member Author

@andymantell We've discussed this and we think that the most sensible thing to do is to hold this back until the next breaking release since we don't have evidence that it's causing users problems. We will then go with the default value of / for the href which seems sensible given that the home page of the service will often be the root url. We will also flag this change in the release notes to ensure that teams are aware of the change.

The alternative to output a <span> is complicated by the fact that the existing class that styles the text is govuk-header__link--service-name which doesn't really makes sense for a span element. We would have therefore had to rename the class which is also a breaking change, and also to introduce some extra functionality in the template to swap the element out, even though we don't have any evidence that a service name without a link is something that teams need to do.

But thanks for offering to work on this, it's much appreciated 🙌

@matthewmascord
Copy link
Contributor

Hello, we have some interesting edge cases where there is a need to provide a serviceName in the header without providing a serviceUrl to that service. Was there any rationale originally around forcing the serviceName to be hyperlinked?

@36degrees 36degrees added the awaiting triage Needs triaging by team label Jan 13, 2021
@timpaul timpaul removed the awaiting triage Needs triaging by team label Jan 13, 2021
@timpaul
Copy link
Contributor

timpaul commented Jan 13, 2021

Thanks @matthewmascord - could you give us a little more detail about the use case you described, where there was no link? It will help us to understand what guidance we need to write, if any.

@timpaul
Copy link
Contributor

timpaul commented Jan 13, 2021

Agreed in Team Triage that, as an MVP, we will swap out the a for a span if no URL is provided.

@matthewmascord
Copy link
Contributor

Hello @timpaul, thanks for getting back. I think the main valid use case is where you have a page relating to a number of different services. You might want to include a generic service name to distinguish it from Gov.UK but not have a unique meaningful place to take users back to if they click the service name.

@36degrees
Copy link
Contributor

As discussed in the v4 scoping session, we can avoid making this a breaking change by introducing a new class name that doesn't include the word link, whilst keeping the existing class name but deprecating it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
header 🕔 hours A well understood issue which we expect to take less than a day to resolve. nunjucks
Projects
7 participants