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

Form input prefixes and suffixes #134

Open
timpaul opened this issue Apr 9, 2018 · 46 comments
Open

Form input prefixes and suffixes #134

timpaul opened this issue Apr 9, 2018 · 46 comments
Labels
component Goes in the 'Components' section of the Design System variant

Comments

@timpaul
Copy link
Contributor

timpaul commented Apr 9, 2018

Update: This proposal was approved by the Design System working group in June 2020. See #134 (comment) for more details.

Earlier review:
Update: This proposal was rejected by the Design System working group on 13 April 2018. See the comments for more details.


What

Prefixes and suffixes on form inputs.

image

Why

Prefixes and suffixes are useful for any service that needs to ask for things like measurement units, currencies, percentages, area codes etc.

Anything else

Here's a prototype showing some proposed guidance and examples

The code is on GitHub here

@timpaul timpaul created this issue from a note in GOV.UK Design System Community Backlog (Proposed) Apr 9, 2018
This was referenced Apr 9, 2018
@edwardhorsford
Copy link

Some thoughts:

The gap between input text and right aligned suffixes can get quite large. I wonder if there's any solutions to this. Off the top of my head:

  • Right align all input on this
  • Size the fields dynamically to the content
  • Leave as is

Will js be included to swallow characters matching the prefix?

The telephone one makes me slightly uncomfortable as it's something that users may want to change - I presume they can't. I guess the label could be 'UK telephone number' - but then is the prefix necessary? It may be easier to treat international phone numbers as a separate pattern to be researched.

@timpaul
Copy link
Contributor Author

timpaul commented Apr 10, 2018

Thanks Ed. I think the suffix issue is one to keep an eye on. My hunch is that suffixes are typically used for things that have a relatively short or known length, like numbers - but of course there will be exceptions.

Good call about swallowing the prefix/suffix characters. Feels like a future enhancement rther than something that should block publication?

Yes, telephone numbers would need an additional control that lets you change the country - which would then automatically update the country code prefix.

@timpaul timpaul self-assigned this Apr 10, 2018
@NickColley
Copy link
Contributor

NickColley commented Apr 10, 2018

Do we need to associate this information in anyway for users with access needs?

If the +44 input indicates that we are looking for a UK telephone number, should that be repeated in a hint?

@edwardhorsford
Copy link

I think it would be good to treat international numbers as a separate pattern.

My hunch for something to try:
Phone number prefix
[custom autocomplete]

Telephone number
[ ]

I wouldn't have the prefix in the number - I'd just treat it as a separate field.

@alphagov alphagov deleted a comment from edwardhorsford Apr 11, 2018
@abbott567
Copy link

We had this conversation on our service for when agents were entering Child Benefit numbers. They always start CHB, so should we just prefix the input? But then what happens if I type CHB into the field. Is it now CHBCHB? Is that a validation error? Because, technically you've added a valid number, but the prefix made it invalid.

In the end, we just accepted it was probably better to let the agents put it in how they wanted, with or without the prefix, and do some work to sanitize and format it in the backend.

@joelanman
Copy link
Contributor

are there any examples of services that use suffixes and prefixes?

@stevenaproctor
Copy link

@timpaul I am in the middle but slightly more down so I voted 👎

In the examples, all of the prefixes and suffixes are hidden from screen readers, making them just a visual enhancement. This is fine but how do we give this extra information to those users without loads of visuallyhidden text or aria-hidden=true? That seems over the top to me when the user need can be achieved with better content and labels.

Similar to what @abbott567 said, we would still need to be deal with people who repeat the suffix or prefix.

@joelanman I have seen a lot of pound signs used outside of inputs like on Pay your Self Assessment and occasionally seen things after inputs too but cannot think of the service.

Both are usually in <span>s and can seem random when you use a screen reader, especially the suffix because it is read out after you leave the field.

@edwardhorsford
Copy link

@stevenaproctor

I'm pretty sure there's a hidden label too that's attached to the field. When we tested them as part of the patterns work last year, each had hidden text. Something along the lines of "Ticket price in £".

I suspect most suffixes should still get read out beforehand. Something like "Total weight in kg, INPUT". Not all of them need to be announced - I think "Percent complete" is correct as it is. Keeping the visual treatment and the labels separate works well for this - services will need to decide on the most appropriate label.

In terms of repeating suffix or prefix - depending on use case, I think we could swallow those characters - but regardless services will need to deal with them on the backend - just like they strip whitespace on postcodes. Services should be able to deal with "£2.56" and "2" etc.

@edwardhorsford
Copy link

@joelanman

We had a prefix on passports for the tracking number:
screen shot 2018-04-12 at 12 39 15

We didn't swallow the "PEX" characters if users typed them, but would have stripped them on the backend.

If I were doing it again I'd have the prefix inside the box as per the designs above (which I subsequently worked on).

@stevenaproctor
Copy link

@edwardhorsford There is visuallyhidden text in the label but it seems over-engineered to me. You could say 'Ticket price in pounds' and that would work for everyone. They do look like mini-buttons too.

@timpaul
Copy link
Contributor Author

timpaul commented Apr 12, 2018

Thanks everyone, this is really useful. So, what I think @stevenaproctor and @abbott567 are suggesting is something more like this?:

image

@tspear
Copy link

tspear commented Apr 13, 2018

I voted down too, I agree with the 'mini-buttons' comment and I wonder whether the user need is better served with hints or examples?. So not sure about useful/unique here.

@cathydutton
Copy link

I’m also leaning towards a thumbs down,

•	Is there a clear user need for this or do we have evidence of users failing to recognise units in labels?
•	Would this pattern replace units being placed in labels/hint text or be used alongside? 

Could this be useful in situations where multiple units are accepted?

@jonhurrell
Copy link

jonhurrell commented Apr 13, 2018

I built the prefix this was based on for the budgeting loans service to denote loan amount as pounds. I was hesitant to see any utility over a label, until I went to a job centre and saw people struggle trying to find and execute the keyboard shortcut for the pound glyph. For those that entered it within the input, we allowed it and stripped it out on post.

I saw no evidence of people trying to click them as buttons, especially given the context of using a service, where a button or action convention is pre-established.

Is there a reason people with dyslexia may prefer unit glyphs over label, or vice-versa?

@stevenaproctor
Copy link

@jonhurrell The British Dyslexia Style Guide says "Pictograms and graphics help to locate information." which could explain people struggling to find the £ on a keyboard. This is the principle behind Easy Read documents too.

The examples could use both words and symbols. Something like 'Ticket price in pounds (£)'.

@timpaul
Copy link
Contributor Author

timpaul commented Apr 16, 2018

Thanks to everyone who reviewed and voted on this proposal. The final result was 3 votes for and 4 against, so we won't be developing this component for now.

In summary, there's not enough evidence that this component meets needs that can't be equally met by other components like form labels.

We'll move this card to the 'Not doing' column where it can act as a record of this decision.

@timpaul timpaul moved this from Proposed to Not doing in GOV.UK Design System Community Backlog Apr 16, 2018
@timpaul timpaul changed the title Add prefixes and suffixes to form inputs Form input prefixes and suffixes Apr 16, 2018
@edwardhorsford
Copy link

Long comment incoming.

I'm rather sad with this result. I hope it can be reconsidered.

If there's still discussion going on, I suggest giving people a chance to address concerns before having a vote. As it is, I don't think there's yet a firm proposal for what the design might look like, with different people commenting on different designs.


Reasons

This is a really common pattern already in use across many government services. It would be great for us to standardise our approach and provide an accessible solution. I see people asking for code snippets for it really regularly.

I feel like some of the concerns raised here are about whether they're always necessary. There will absolutely be cases where they might not be - such as @abbott567's case number example. Does that mean we shouldn't have a pattern for it though? or that we should let services use their judgement and research to determine when it's helpful.

The other concern I see is about services having to deal with the prefix or not - but services already need to deal with this regardless of the pattern. It's part of doing the hard work to make it simple. In Craig's example, I wouldn't expect the prefix to get submitted - so the server will either get CAB12345 or 12345 - regardless of the prefix it should arguably deal with both.

The prefix the patterns team at GDS built last year had it styled like this:
screen shot 2018-04-16 at 13 45 02

We tested this across three rounds of research and it worked well. The styling avoided the potential for it looking like a button (though I'm not too worried about that).

I think changing the label to "Approximate cost for tickets in £" would be detrimental and make the label too complex.


Prefixes in labels

I have concerns with the suggestion of standardising on adding prefixes to labels - and don't think it works in all situations.

The labels are the most important part of the field, whereas prefixes are extra visual touches that help by adding affordance to the field. They should be secondary to the label. Adding them to labels makes the labels longer and more complex - possibly harder to read.

There'll also be cases where it really doesn't work with the label. Here's an example from HMRC self service:
screen shot 2018-04-16 at 14 27 10

And one from Help with fees:
screen shot 2018-04-16 at 13 39 57
In these cases, I think adding it to the label would be really weird. You could argue it doesn't have to have a prefix at all, but I personally think it's a nice extra touch.

NB: There are probably cases where the unit works really well as the label. Services should be free to choose between the two depending on user need.

Other examples

Here's some more examples we collected prior to our research last year. We were only looking at currency input - so I don't have examples of other types of prefixes. We judged that currency input would be by far the most common form of prefixed input.

Office of the Public Guardian

screen shot 2018-04-16 at 15 09 47

Digital Marketplace

digital marketplace 2

Pensions

screen shot 2018-04-16 at 15 11 13

HMRC Personal allowance calculator

screen shot 2018-04-16 at 15 11 37

HMRC unknown service

screen shot 2018-04-16 at 15 12 38

@jonheslop
Copy link

jonheslop commented Apr 20, 2018

FWIW GOV.UK Pay use @edwardhorsford and @hannalaakso’s markup from the their research last year and it works well for us

currency-input

Code: https://github.com/alphagov/pay-selfservice/blob/a06ba1074f4f099f7bdd47e1a0b802a0d2d4d46c/app/views/dashboard/demo-service/create.njk#L20-L29

@timpaul timpaul added the component Goes in the 'Components' section of the Design System label May 21, 2018
@vickytnz
Copy link

I feel like there's something in investigating the different options available - including the default if we can't have this of how we ask for money. I know that the design system feedback format has iterated - this could be worth investigating more and then bringing back in another format?

(I'm interested in this for reasons such as how we encourage people to input in GBP - or allow them to put money in a different currency and do conversions on the backend ...)

@frankieroberto
Copy link

Here's another example from the NHS, which uses suffixes for weight and height units as part of their BMI calculator:

Metric:
screen shot 2018-08-10 at 11 17 11

Imperial:
screen shot 2018-08-10 at 11 17 54

@kellylee-gds kellylee-gds moved this from Not doing to In progress in GOV.UK Design System Community Backlog May 22, 2020
@hannalaakso
Copy link
Member

GOV.UK Design System working group review

Representatives from the GOV.UK Design System working group reviewed a prefixes/suffixes variant for text input in June 2020.

Based on a majority vote, the group decided that:

  • The contribution can be published as is

They also made the following recommendations.

Guidance

  • Create a pattern for asking users to enter an amount of something
  • Create a pattern for asking users to choose the unit or measurement

Design

  • Consider whether users could confuse the grey background of the prefix/suffix container with a button

Code

  • Ensure that the variant works for longer prefixes/suffixes on smaller screens
  • Investigate generating the prefix/suffix for the label text with the Nunjucks macro

Next steps

Based on this feedback, the GOV.UK Design System team and the contributor have agreed to:

  • Improve the wording of the guidance to make it clear there needs to be an association between the input label text and the associated prefix/suffix
  • Ensure that the variant works on smaller viewports, up to a point AND
  • Add a recommendation for when the variant should not be used (eg. with very long or complex prefixes/suffixes)

We don’t think we currently have enough information to create a wider pattern for asking users to enter an amount, or a pattern to help users to choose the unit or measurement from a number of options. For this reason we will record these two recommendations here in the backlog, and will keep an eye on how the prefixes/suffixes variant gets used by services to gain a better understanding of the requirements for related patterns.

We decided not to investigate how the Nunjucks macro could generate the label text from the prefix or suffix. This is because the feature would not benefit the users of the HTML version and would necessitate different guidance to the HTML version. It might also not be possible to support the feature once GOV.UK Frontend can support localisation to different languages.

We currently don’t have evidence that the grey background of the prefix/suffix container is a usability issue. MOJ, HMRC and GOV.UK have all used a variant with a grey background on their services. However we should keep an eye out for any related issues. The variant also allows the background colour to be overridden with a class so teams can adapt it to suit the specific requirements of their service.

@MalcolmVonMoJ
Copy link

I think click area should include the prefix/suffix box as well as the main input box, so that if a user clicks on the prefix box, the input receives the focus.

I made a quick mock-up of this behaviour by altering the CSS of one of our current currency fields:

Click Area Currency

@hannalaakso
Copy link
Member

@MalcolmVonMoJ Thanks for the suggestion. It would be good if this interaction could be tested with users. For instance if you have both a prefix and a suffix, could users think that something "happens" or is activated when you click the prefix or the suffix, and might users think that whatever "happens" is different depending on whether you click the prefix or the suffix? It would be useful to hear any findings from teams.

@MalcolmVonMoJ
Copy link

@hannalaakso

The only thing I can offer now (and I have mentioned it before, so this might seem familiar) is some user research from the MoJ regarding currency fields. Some users were reported as thinking that the grey box around the prefix (as found on the MoJ Design System) was a button to change the currency (£, $, € etc). For this reason, many services opted to drop the grey background for a clear one (you can see the pattern we all use in the video I posted). However I don't know any more than that - the user research and design decision preceded my joining the team - I was just told the results. I would assume that a similar behaviour might be witnessed for suffixes (kg, lb, st etc).

However, now that the Design System working group has decided on this pattern, I was just trying to suggest that the prefix and suffix should be considered part of the input. If users were expecting the currency to change, the input box receiving focus might inform them that typing in is all they can do. If nothing happens, that might lead to a moment's confusion.

I think we have a new round of user research and testing on the horizon, I'll suggest that we make the changes as seen here and see what the results are. However, most of our currency fields have a selectable suffix as can be seen in the video (select: per week, per month etc), so might not be ideal for testing this pattern.

Hope that all makes sense (and is useful).

@edwardhorsford
Copy link

I like @MalcolmVonMoJ's suggestion. It loosely follows the existing pattern that clicking on an input label will focus an input.

@hannalaakso
Copy link
Member

I think we have a new round of user research and testing on the horizon, I'll suggest that we make the changes as seen here and see what the results are.

@MalcolmVonMoJ It would be great if you could post findings from relevant user research here. We hope to publish the new prefix/suffix variant within the next month so it'll be available for testing then. If you need to combine it with a pattern for choosing the unit it would still be useful to document the findings here.

@lfdebrux

This comment has been minimized.

@hannalaakso hannalaakso moved this from In progress to Published in GOV.UK Design System Community Backlog Sep 15, 2020
@timpaul
Copy link
Contributor Author

timpaul commented Sep 28, 2020

I think click area should include the prefix/suffix box as well as the main input box, so that if a user clicks on the prefix box, the input receives the focus.

I made a quick mock-up of this behaviour by altering the CSS of one of our current currency fields:

Click Area Currency

Hi @MalcolmVonMoJ - did you have any results with your suggestion of making clicking on prefixes and suffixes focus their input?

@MalcolmVonMoJ
Copy link

Hi @timpaul

In regards to user research, I'm afraid not. All our currency inputs are using this approach, but the round of user research that I was hoping would look at this didn't look at this part of the service. I am still hoping to have this included in the next round of research in this part of the service. The previous pattern (without the grey border) worked well, and that had an identical click area with this one.

In regards to technical implementation, it is quite easy (we had to make an unexpected adjustment in the CSS for Firefox as this behaves slightly differently, but this was also easy).

However, we just did it for currency input where the size of the prefix is constant - this means that the padding can be fixed in the CSS.
image

I was thinking about this last week and if you cannot be sure what the width of the prefix is, then the padding either has to be changed by the developer for each input or be a set by JavaScript.

Given that the pattern is published, it might be best to just write a bit of JavaScript to get the width of the prefix and then change the padding for the input element accordingly.

With our setup, we only use JavaScript for a slight adjustment to the error state. As the whole area is selectable, we initially highlight the whole box in red.

image

We then use JS to change the black prefix border to red too - as it is a little odd to leave this black.

image

@frankieroberto
Copy link

frankieroberto commented Sep 29, 2020

I like the "honesty", as I think @timpaul put it, of having only the input area highlight on error or focus. This also avoids any overlaps where browsers add icons within the form fields (eg for autofill).

Possibly having the input field focus if the prefix or suffix boxes are clicked could be considered as a javascript enhancement though?

@timpaul
Copy link
Contributor Author

timpaul commented Sep 29, 2020

Thanks for the suggestions @MalcolmVonMoJ and @frankieroberto - I've raised an issue for this idea here: alphagov/govuk-frontend#1973

@timpaul
Copy link
Contributor Author

timpaul commented Oct 2, 2020

Following up on @edwardhorsford s comment here: #134 (comment)

Here's how Paypal do it...

currency

So less of an input mask, more of a placeholder hint?

@edwardhorsford
Copy link

@timpaul that's different than what I was describing.

@timpaul
Copy link
Contributor Author

timpaul commented Oct 2, 2020

Hah, yeah I see that now - that Paypal use case is pretty limited

@lalexander12
Copy link

When asking about pounds (currency) can I ask if we always need to spell out the pounds?

eg, Tell us how much you have in your bank account, in pounds?

There's lots of examples on this thread where people aren't saying the 'in pounds' bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component Goes in the 'Components' section of the Design System variant
Development

No branches or pull requests