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

Fix rendering of Back link's href and text for falsy values #5191

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

romaricpascal
Copy link
Member

Reverts to the behaviour of 5.4.0, which ensured consistency across falsy values, and importantly that a 'Back' text was displayed in case of empty strings (and a '#' value for the href attribute, but there's less difference with a '').

Adds tests to ensure we keep an eye on the behaviour in future template changes, or at least make sure that any deviation is intentional (and tested).

Instead of reverting the commit, I used the boolean option from Nunjucks' default filter to keep the tidy up of the templates introduced in fc704d1.

Fixes #5189

Copy link

github-actions bot commented Aug 2, 2024

📋 Stats

File sizes

File Size
dist/govuk-frontend-development.min.css 112.61 KiB
dist/govuk-frontend-development.min.js 41.83 KiB
packages/govuk-frontend/dist/govuk/all.bundle.js 87.33 KiB
packages/govuk-frontend/dist/govuk/all.bundle.mjs 82.03 KiB
packages/govuk-frontend/dist/govuk/all.mjs 981 B
packages/govuk-frontend/dist/govuk/govuk-frontend-component.mjs 359 B
packages/govuk-frontend/dist/govuk/govuk-frontend.min.css 112.6 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend.min.js 41.82 KiB
packages/govuk-frontend/dist/govuk/i18n.mjs 5.55 KiB
packages/govuk-frontend/dist/govuk/init.mjs 4.86 KiB

Modules

File Size (bundled) Size (minified)
all.mjs 79.16 KiB 39.79 KiB
accordion.mjs 23.5 KiB 12.39 KiB
button.mjs 5.98 KiB 2.69 KiB
character-count.mjs 22.4 KiB 9.92 KiB
checkboxes.mjs 5.83 KiB 2.83 KiB
error-summary.mjs 7.89 KiB 3.46 KiB
exit-this-page.mjs 17.1 KiB 9.26 KiB
header.mjs 4.46 KiB 2.6 KiB
notification-banner.mjs 6.26 KiB 2.62 KiB
password-input.mjs 15.15 KiB 7.25 KiB
radios.mjs 4.83 KiB 2.38 KiB
skip-link.mjs 4.39 KiB 2.18 KiB
tabs.mjs 10.05 KiB 6.06 KiB

View stats and visualisations on the review app


Action run for 6d99967

const $component = document.querySelector('.govuk-back-link')
expect($component).toHaveAttribute('href', '/home')
it.each(['', 0, false, null, undefined])(
'displays `Back` for `%s`',
Copy link
Member

Choose a reason for hiding this comment

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

I think this test is misnamed, as it appears to be testing whether href is # when a value is falsy or undefined, not the link text.

The test for the link text is on line 78.

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, good catch, I'll rename.

Copy link
Member

@querkmachine querkmachine left a comment

Choose a reason for hiding this comment

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

One note about a test having the wrong name, but otherwise this seems to do what it sets out to do, and it has tests now! Hurray!

Reverts to the behaviour of 5.4.0, which ensured consistency across falsy values, and importantly that a 'Back' text was displayed in case of empty strings (and a '#' value for the `href` attribute, but there's less difference with a '').

Instead of reverting the commit, I used the `boolean` option from Nunjucks' `default` filter to keep the tidy up of the templates introduced in fc704d1.
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-5191 August 6, 2024 08:44 Inactive
@romaricpascal romaricpascal merged commit 85f5de1 into main Aug 6, 2024
50 checks passed
@romaricpascal romaricpascal deleted the fix-back-link-falsy-values branch August 6, 2024 09:04
@romaricpascal romaricpascal mentioned this pull request Aug 9, 2024
querkmachine pushed a commit that referenced this pull request Aug 19, 2024
Fix rendering of Back link's `href` and `text` for falsy values
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.

Restore behaviour of Back Link component for falsy text and href options
3 participants