diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c839ded94..0ea69a8c17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ For advice on how to use these release notes see [our guidance on staying up to We've made fixes to GOV.UK Frontend in the following pull requests: +- [#5046: Skip ‘empty’ tasks in the task list](https://github.com/alphagov/govuk-frontend/pull/5046) - [#5066: Fix whitespace affecting text alignment in pagination block variant](https://github.com/alphagov/govuk-frontend/pull/5066) ## 5.4.1 (Fix release) diff --git a/packages/govuk-frontend/src/govuk/components/task-list/task-list.yaml b/packages/govuk-frontend/src/govuk/components/task-list/task-list.yaml index ac5efe123a..a2d41c13fd 100644 --- a/packages/govuk-frontend/src/govuk/components/task-list/task-list.yaml +++ b/packages/govuk-frontend/src/govuk/components/task-list/task-list.yaml @@ -376,3 +376,21 @@ examples: status: tag: html: Tag + + - name: with empty values + options: + items: + - + - null + - title: + text: Task A + href: '#' + status: + text: Completed + - false + - '' + - title: + text: Task B + href: '#' + status: + text: Completed diff --git a/packages/govuk-frontend/src/govuk/components/task-list/template.jsdom.test.js b/packages/govuk-frontend/src/govuk/components/task-list/template.jsdom.test.js index 63956d58c9..c21f7cc118 100644 --- a/packages/govuk-frontend/src/govuk/components/task-list/template.jsdom.test.js +++ b/packages/govuk-frontend/src/govuk/components/task-list/template.jsdom.test.js @@ -281,4 +281,10 @@ describe('Task List', () => { expect($link).toHaveAttribute('aria-describedby') }) }) + + it('omits empty items from the task list', () => { + document.body.innerHTML = render('task-list', examples['with empty values']) + + expect(document.querySelectorAll('.govuk-task-list__item')).toHaveLength(2) + }) }) diff --git a/packages/govuk-frontend/src/govuk/components/task-list/template.njk b/packages/govuk-frontend/src/govuk/components/task-list/template.njk index 6ce4bcd876..19c284146b 100644 --- a/packages/govuk-frontend/src/govuk/components/task-list/template.njk +++ b/packages/govuk-frontend/src/govuk/components/task-list/template.njk @@ -36,6 +36,6 @@