govuk-design-system-backlog icon indicating copy to clipboard operation
govuk-design-system-backlog copied to clipboard

Date input

Open govuk-design-system opened this issue 7 years ago • 74 comments

Use this issue to discuss this component in the GOV.UK Design System.

Anything else

Related to the 'date picker' component issue

govuk-design-system avatar Jan 12 '18 15:01 govuk-design-system

Consider how some users might be entering a date from reading it off material where it's displayed as letters. e.g. a passport.

so consider allowing various formats for month e.g. 3, 03, MAR and MARCH

in our testing we see users enter months as numbers

davehaigh avatar Jul 13 '18 10:07 davehaigh

There used to be documentation with this component explaining a hack to make inputs work as users expected in iOS (specifically activating the numeric keyboard on number inputs). Is this still relevant? I notice it's not in the current page

manalishi79 avatar Aug 01 '18 13:08 manalishi79

There used to be documentation with this component explaining a hack to make inputs work as users expected in iOS (specifically activating the numeric keyboard on number inputs). Is this still relevant? I notice it's not in the current page

Hi Paul,

It's still relevant – I believe that guidance was removed because we are now providing code examples, which we were not able to do when this content was in the service manual, and so it was more important to document 'implementation details' like that.

The code examples on the date input all use the pattern="[0-9]*" attribute, which triggers the keyboard on iOS.

36degrees avatar Aug 02 '18 08:08 36degrees

Testing the "Apply for a Blue Badge" service. We saw two users with Voiceover on iOS run into issues when entering their date of birth. The first user expected it to auto-tab, getting stuck in the day field and then had issues getting back into the month field. The second user wasn't sure of what to do after entering the day, they said “I didn’t hear that one. Do I have to put dot there for month? Oh I have to go, ok. I’ve just done the day, and then” he then tried to find the dot button and gets stuck in the International keyboard, swiping the screen he finds year… swipes the screen until he finds the month input “I just want to go to month”.

charge-valtech avatar Aug 22 '18 13:08 charge-valtech

I don't think the documentation specifically shows how to display a formatted date. It has "31 3 1980" in the examples, but this is not specifically spelt out in date patterns or a-z style guide. One of the reasons this has come up is that in my 30 years of non-government development, I've never come across a date format (anywhere in the world) where spaces are the separator!

Soundman32 avatar Oct 08 '18 09:10 Soundman32

Hello all. I'd like to understand why the text input based date picker is more usable / accessible than more a select element, or a calendar. Could you tell me or point me in the right direction?

I remember that there's been usability findings pointing to that direction, but it'd help me to understand what the these findings so I can be convinced myself and convince colleagues. Is there an article / blog post anywhere recapping on this?

(Thanks for the excellent work on the design system and its documentation).

jfhector avatar Oct 23 '18 19:10 jfhector

Hi @jfhector that's a good question, you can read some research here:

https://designnotes.blog.gov.uk/2013/12/05/asking-for-a-date-of-birth/

We found similar problems with dropdowns regularly, which is why we generally recommend against them.

In terms of calendar controls, we haven't found a need when it comes to asking for a memorable date (like a date of birth), though it could be useful in other situations. The problem then is, if you use built-in browser calendars the user experience can vary wildly. If you use a custom calendar control you need to make sure it's fully accessible.

joelanman avatar Oct 24 '18 09:10 joelanman

I always point people at @alicebartlett's talk about dropdowns from 2014. https://www.youtube.com/watch?v=CUkMCQR4TpY&t=1s

stevenaproctor avatar Oct 24 '18 09:10 stevenaproctor

Thanks a lot @joelanman @stevenaproctor , really helpful.

jfhector avatar Oct 24 '18 17:10 jfhector

Have any prototypes / services considered a 'today' option on a date entry screen, so a user can - for example - select a 'today' radio button rather than enter data into the date fields under it? I realise it would often be inappropriate but for some services where a user can cancel / deregister on that particular day it might be helpful?

jonathaninch avatar Nov 06 '18 14:11 jonathaninch

is there a way to add attributes to date items, such as maxlength=2 and aria-required=true

HughePaul avatar Feb 07 '19 16:02 HughePaul

is there a way to add attributes to date items, such as maxlength=2 and aria-required=true

This isn't possible using the macros at the minute – this is being tracked as an issue in the GOV.UK Frontend repo – https://github.com/alphagov/govuk-frontend/issues/995.

If you're using the HTML directly, then you can add the attributes as you normally would.

36degrees avatar Feb 08 '19 15:02 36degrees

While testing this pattern in the design system with Safari and Voiceover, I've noticed that the text inputs offer a number input as an incrementable input (stepper). I can't see how this input format is described in the markup.

manalishi79 avatar Feb 12 '19 17:02 manalishi79

At https://design-system.service.gov.uk/patterns/dates/ the first example is '01 08 2007' and the second example is '31 3 1980'. This is a minor inconsistency but we should fix it.

I've encountered users who believe they must use leading zeros because it's in the example on the service they're using. Even though the day and month are labelled, I think it's beneficial for the example to emphasise the distinction between day and month by using a day number that can't be a month number.

I propose the guidance is updated as follows:

  1. Day and month fields should accept input with and without leading zeros
  2. The example month number should illustrate a leading zero isn't mandatory i.e in the range 1 to 9.
  3. The example day number should illustrate it's day before month rather then month before day i.e. in the range 13 to 31
  4. The examples in the guidance should be updated to reflect the above.

terrysimpson99 avatar Apr 01 '19 10:04 terrysimpson99

Hi Terry,

That sounds like a sensible improvement. Would you be interested in creating a pull request with those changes?

I think you'd need to edit…

This line to update the first example: https://github.com/alphagov/govuk-design-system/blob/master/src/patterns/dates/default/index.njk#L19

This line to update the last (error state) example: https://github.com/alphagov/govuk-design-system/blob/master/src/patterns/dates/error/index.njk#L20

And add any additional guidance to the pattern itself: https://github.com/alphagov/govuk-design-system/blob/master/src/patterns/dates/index.md.njk

Let me know if I can help at all.

Thanks,

Ollie

36degrees avatar Apr 15 '19 15:04 36degrees

Thanks Ollie. I've never done a pull request before but I'd like to try. I'll ask a colleague for help and give it a go. Hopefully in the next week.

Terry

terrysimpson99 avatar Apr 16 '19 08:04 terrysimpson99

Recording an issue from @andysellick (https://github.com/alphagov/govuk-frontend/issues/1250) and a PR from @colinrotherham (https://github.com/alphagov/govuk-frontend/pull/1257) we need to consider how this component should adapt based on available size.

While the component holds together inside a single column at our minimum supported breakpoint (320px) it will break if put inside a container smaller than this (such as a search filter panel), especially on tablet or desktop as the font size will be bigger (we are sizing the inputs with the ex unit the input width changes based on font-size).

Things to potentially consider when the space available cannot contain the 3 inputs inline:

  • Stack all 3 inputs on top of each other
  • Reduce space between inputs
  • Change the input size (It's currently slightly oversized)
  • Consider mobile breakpoint design vs limited width container design
  • Consider using flexbox / grid

dashouse avatar Apr 17 '19 12:04 dashouse

When used with a Welsh translation, the day and month fields do not have adequate spacing between them:

welsh

(Reported on Slack by Jonathan King, Content Designer at DWP)

paulwaitehomeoffice avatar Apr 23 '19 11:04 paulwaitehomeoffice

@paulwaitehomeoffice As @colinrotheram has pointed out this example appears to be from an alternate frontend. GOV.UK Frontend behaves like this:

Screen Shot 2019-04-23 at 13 26 23

dashouse avatar Apr 23 '19 12:04 dashouse

@dashouse Ah, sorry, I missed that.

paulwaitehomeoffice avatar Apr 23 '19 14:04 paulwaitehomeoffice

Why are we using a pattern attribute on a number input type?

The pattern attribute is an attribute of the text, tel, email, url, password, and search input types.

https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern

philsherry avatar Dec 07 '19 14:12 philsherry

@philsherry although it's technically invalid according to the specification, this was the best way to reliably trigger the numeric keyboard on older versions of iOS (< iOS 9.3 IIRC) – unfortunately using input type="number" doesn't do it by default.

Thankfully things have moved on, and we now have an issue open to update the date input to use inputmode, but we've been able to prioritise it yet.

36degrees avatar Dec 09 '19 09:12 36degrees

  1. The page uses '11' as a month number. I propose it's amended to bring it in line with the guidance: "If you give an example date, use 13 or more for the day and 9 or less for the month - for example ‘27 3 2007’. This helps users enter the date in the correct order and shows them they do not need to include leading zeroes." https://design-system.service.gov.uk/patterns/dates/. Is this possible?

  2. When I started looking for guidance, I didn't realise it was in two places: https://design-system.service.gov.uk/patterns/dates/ and https://design-system.service.gov.uk/components/date-input/. This meant I only followed guidance on one of the pages. Perhaps others have a similar experience. What would happen if the two pages were merged?

terrysimpson99 avatar Mar 19 '20 09:03 terrysimpson99

Has anyone, by any chance, implemented this as a react component?

tbrd avatar Mar 24 '20 10:03 tbrd

Couple of quick questions from me:

  1. What should the error message be if the user enters a non-numeric date part (or parts), eg:
Screenshot 2020-07-24 at 16 55 11
  1. Should we try to parse known month strings like "March" or "DEC" or not?

frankieroberto avatar Jul 24 '20 16:07 frankieroberto

image

[Whatever it is] must have a year that is a number.

The full list of error messages we use currently is:

Day field and month field blank = "Effective date must include a day and month" Day field and year field blank = "Effective date must include a day and year" Day field only contains a non-digit = "Effective date must have a day that is a number" Day field contains an unacceptable number (leading zero is acceptable) = "Effective date must have a day that is a number between 1 and 31"

Month field only is blank = "Effective date must include a month" Month and year field blank = "Effective date must include a month and year" Month field contains a non-digit = "Effective date must have a month that is a number" Month field contains an unacceptable number (leading zero is acceptable) = "Effective date must have a month that is a number between 1 and 12"

Year field only is blank = "Effective date must include a year" Year field contains a non-digit = "Effective date must have a year that is a number"

All three fields blank = "Enter an effective date"

Date not between 1 april 1993 and today = "Effective date must be between 1 April 1993 and today" Year is not four digits = "Effective date must be between 1 April 1993 and today"

We don't translate 'March' or 'DEC'. Research has been done on this topic and I saw a presentation showing significant disadvantages. Maybe somebody can give you a reference.

terrysimpson99 avatar Jul 24 '20 16:07 terrysimpson99

"Effective date must have a day that is a number" - why are you allowing them to type in non-numbers in the first place?

Soundman32 avatar Jul 25 '20 09:07 Soundman32

@Soundman32 The number type is more problematic than it seems: https://technology.blog.gov.uk/2020/02/24/why-the-gov-uk-design-system-team-changed-the-input-type-for-numbers/

anevins12 avatar Jul 25 '20 09:07 anevins12

Guidance on date input says "If there's more than one error, show the highest priority error message. In order of priority, show error messages about: missing or incomplete information; information that can't be correct (for example, the number '13' in the month field); information that fails validation for another reason" What it says appears generally applicable rather than only true for dates.

I raised this no Slack and the consensus appears to be that: (a) it's generally applicable and may belong in general guidance about error handling; and (b) it may need amending to reduce the chance of a user encountering one error message after another.

@StephenGill

terrysimpson99 avatar Aug 27 '20 13:08 terrysimpson99