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

Remove abbr tag from contents list link #3241

Merged
merged 1 commit into from
Jun 27, 2024
Merged

Remove abbr tag from contents list link #3241

merged 1 commit into from
Jun 27, 2024

Conversation

andysellick
Copy link
Contributor

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

What / why

  • this page https://www.gov.uk/government/history/1-horse-guards-road calls the contents_list component and passes a series of links including one that includes an abbr (abbreviation) tag to explain the acronym 'GOGGS'
  • this acroynm is explained several times already in the text of the page, as well as in the contents list link that immediately precedes this one
  • there is no need for this tag inside this link, and this also causes significant complexity for the contents list component, which should not have anything other than text passed to it for the value of the text of a link

Visual changes

Before After
Screenshot 2024-06-27 at 09 29 19 Screenshot 2024-06-27 at 09 29 25

- this page https://www.gov.uk/government/history/1-horse-guards-road calls the contents_list component and passes a series of links including one that includes an abbr (abbreviation) tag to explain the acronym 'GOGGS'
- this acroynm is explained several times already in the text of the page, as well as in the contents list link that immediately precedes this one
- there is no need for this tag inside this link, and this also causes significant complexity for the contents list component, which should not have anything other than text passed to it for the value of the text of a link
@andysellick andysellick requested a review from KludgeKML June 27, 2024 08:35
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3241 June 27, 2024 08:35 Inactive
Copy link
Contributor

@KludgeKML KludgeKML left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@andysellick andysellick merged commit 8340fd1 into main Jun 27, 2024
12 checks passed
@andysellick andysellick deleted the remove-abbr branch June 27, 2024 10:11
andysellick added a commit to alphagov/govuk_publishing_components that referenced this pull request Jun 28, 2024
- the contents list component does clever stuff when you pass the `format_numbers` option, where it identifies numbers at the start of the link text, splits the string into two, and wraps the number and text in separate spans so that the spacing between them can be controlled with CSS (otherwise 1. is misaligned with 10.)
- in some circumstances the content arriving at the component has a non-breaking space instead of an actual space, i.e. "1. Text of link", which the component doesn't recognise and fails to split and wrap with spans for nice formatting, e.g. https://www.gov.uk/government/publications/financial-sanctions-guidance-for-russia/financial-sanctions-guidance-for-russia
- this change allows for this situation and converts the non-breaking space into a regular space prior to formatted number checking
- it also changes how the wrapped spans are returned (by now simply extracting the number and remaining text, wrapping them in spans and returning them) instead of a slightly more complex string replacing approach designed to preserve anything outside of the string
- this includes refactoring the code and tests to simplify the code and limit the method to assume that the string passed to it should only be text, not markup, by stripping any HTML from the input
- the helper spec in particular implied that markup (including a wrapping link) should be accepted by the method, but this is unrealistic - the output from the method is always wrapped in a parent (either a link or a span) and should not contain markup, as this is the text of the link, not a free area to inject HTML
- this was being done in one place (to include an abbreviation tag inside the link) but has been corrected, see alphagov/government-frontend#3241
andysellick added a commit to alphagov/govuk_publishing_components that referenced this pull request Jun 28, 2024
- the contents list component does clever stuff when you pass the `format_numbers` option, where it identifies numbers at the start of the link text, splits the string into two, and wraps the number and text in separate spans so that the spacing between them can be controlled with CSS (otherwise 1. is misaligned with 10.)
- in some circumstances the content arriving at the component has a non-breaking space instead of an actual space, i.e. "1. Text of link", which the component doesn't recognise and fails to split and wrap with spans for nice formatting, e.g. https://www.gov.uk/government/publications/financial-sanctions-guidance-for-russia/financial-sanctions-guidance-for-russia
- this change allows for this situation and converts the non-breaking space into a regular space prior to formatted number checking
- it also changes how the wrapped spans are returned (by now simply extracting the number and remaining text, wrapping them in spans and returning them) instead of a slightly more complex string replacing approach designed to preserve anything outside of the string
- this includes refactoring the code and tests to simplify the code and limit the method to assume that the string passed to it should only be text, not markup, by stripping any HTML from the input
- the helper spec in particular implied that markup (including a wrapping link) should be accepted by the method, but this is unrealistic - the output from the method is always wrapped in a parent (either a link or a span) and should not contain markup, as this is the text of the link, not a free area to inject HTML
- this was being done in one place (to include an abbreviation tag inside the link) but has been corrected, see alphagov/government-frontend#3241
andysellick added a commit to alphagov/govuk_publishing_components that referenced this pull request Jul 1, 2024
- the contents list component does clever stuff when you pass the `format_numbers` option, where it identifies numbers at the start of the link text, splits the string into two, and wraps the number and text in separate spans so that the spacing between them can be controlled with CSS (otherwise 1. is misaligned with 10.)
- in some circumstances the content arriving at the component has a non-breaking space instead of an actual space, i.e. "1. Text of link", which the component doesn't recognise and fails to split and wrap with spans for nice formatting, e.g. https://www.gov.uk/government/publications/financial-sanctions-guidance-for-russia/financial-sanctions-guidance-for-russia
- this change allows for this situation and converts the non-breaking space into a regular space prior to formatted number checking
- it also changes how the wrapped spans are returned (by now simply extracting the number and remaining text, wrapping them in spans and returning them) instead of a slightly more complex string replacing approach designed to preserve anything outside of the string
- this includes refactoring the code and tests to simplify the code and limit the method to assume that the string passed to it should only be text, not markup, by stripping any HTML from the input
- the helper spec in particular implied that markup (including a wrapping link) should be accepted by the method, but this is unrealistic - the output from the method is always wrapped in a parent (either a link or a span) and should not contain markup, as this is the text of the link, not a free area to inject HTML
- this was being done in one place (to include an abbreviation tag inside the link) but has been corrected, see alphagov/government-frontend#3241
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants