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

Text input ignoring 0 as value #4669

Closed
Tracked by #3574
dwp-dmitri-algazin opened this issue Jan 23, 2024 · 1 comment · May be fixed by #4770
Closed
Tracked by #3574

Text input ignoring 0 as value #4669

dwp-dmitri-algazin opened this issue Jan 23, 2024 · 1 comment · May be fixed by #4770
Assignees
Labels
🐛 bug Something isn't working the way it should (including incorrect wording in documentation) nunjucks text input
Milestone

Comments

@dwp-dmitri-algazin
Copy link

Description of the issue

If 0 (zero) is a valid field value, govukInput() ignores it, because of this if condition:

{%- if params.value %} value="{{ params.value }}"{% endif %}

As we know from JavaScript, if ( 0 ) returns false, not true

Steps to reproduce the issue

Create govukInput with 0 value

Actual vs expected behaviour

I would expect to see mu input with value 0 in it

Environment (where applicable)

we use DWP Casa framework with latest GOV.UK Frontend Version: 5.0.0

  • Operating system: any
  • Browser: any
  • Browser version: any
  • GOV.UK Frontend Version: 5.0.0

when zero is a number ( 0 )

Screenshot 2024-01-23 at 17 14 21

when zero is a string ( '0' )

Screenshot 2024-01-23 at 17 10 50
@dwp-dmitri-algazin dwp-dmitri-algazin added awaiting triage Needs triaging by team 🐛 bug Something isn't working the way it should (including incorrect wording in documentation) labels Jan 23, 2024
Copy link

Uh oh! @dwp-dmitri-algazin, the image you shared is missing helpful alt text. Check your issue body.

Alt text is an invisible description that helps screen readers describe images to blind or low-vision users. If you are using markdown to display images, add your alt text inside the brackets of the markdown image.

Learn more about alt text at Basic writing and formatting syntax: images on GitHub Docs.

@36degrees 36degrees added nunjucks text input and removed awaiting triage Needs triaging by team labels Jan 23, 2024
@colinrotherham colinrotherham self-assigned this Feb 16, 2024
@colinrotherham colinrotherham removed their assignment Mar 10, 2024
@patrickpatrickpatrick patrickpatrickpatrick self-assigned this Apr 11, 2024
patrickpatrickpatrick added a commit that referenced this issue May 2, 2024
Fixes #4669. Input component now uses govukAttributes macro to validate
and format attributes. Test and example added for edge case outlined in
issue #4669.
patrickpatrickpatrick added a commit that referenced this issue May 2, 2024
Fixes #4669. Input component now uses govukAttributes macro to validate
and format attributes. Test and example added for edge case outlined in
issue #4669.

Co-authored-by: Colin Rotherham <work@colinr.com>
patrickpatrickpatrick added a commit that referenced this issue May 2, 2024
Fixes #4669. Input component now uses govukAttributes macro to validate
and format attributes. Test and example added for edge case outlined in
issue #4669.

Co-authored-by: Colin Rotherham <work@colinr.com>
patrickpatrickpatrick added a commit that referenced this issue May 2, 2024
Fixes #4669. Input component now uses govukAttributes macro to validate
and format attributes. Test and example added for edge case outlined in
issue #4669.

Co-authored-by: Colin Rotherham <work@colinr.com>
patrickpatrickpatrick added a commit that referenced this issue May 7, 2024
Fixes #4669. Input component now uses govukAttributes macro to validate
and format attributes. Test and example added for edge case outlined in
issue #4669.

Co-authored-by: Colin Rotherham <work@colinr.com>
patrickpatrickpatrick added a commit that referenced this issue May 9, 2024
Fixes #4669. Input component now uses govukAttributes macro to validate
and format attributes. Test and example added for edge case outlined in
issue #4669.

Co-authored-by: Colin Rotherham <work@colinr.com>
patrickpatrickpatrick added a commit that referenced this issue May 9, 2024
Fixes #4669. Input component now uses govukAttributes macro to validate
and format attributes. Test and example added for edge case outlined in
issue #4669.

Co-authored-by: Colin Rotherham <work@colinr.com>
@36degrees 36degrees added this to the [next] milestone May 9, 2024
36degrees pushed a commit that referenced this issue May 15, 2024
Fixes #4669. Input component now uses govukAttributes macro to validate
and format attributes. Test and example added for edge case outlined in
issue #4669.

Co-authored-by: Colin Rotherham <work@colinr.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working the way it should (including incorrect wording in documentation) nunjucks text input
Projects
Status: Done 🏁
Development

Successfully merging a pull request may close this issue.

4 participants