Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Use ex instead of ch for better browser consistency #362

Merged
merged 1 commit into from
May 20, 2020

Conversation

SiAdcock
Copy link
Contributor

@SiAdcock SiAdcock commented May 20, 2020

What is the purpose of this change?

Text input fields use the ch unit to set the width based on expected character length.

We have noticed that fields look narrower in IE11 due to the way IE11 calculates the width of 1ch. According to CanIUse:

IE supports the ch unit, but unlike other browsers its width is that specifically of the "0" glyph, not its surrounding space. As a result, 3ch for example is shorter than the width of the string "000" in IE.

The ex unit appears more consistent across browsers. Using this would mean we would not be able to map the expected character length to the actual width of the field.

GOV.UK uses the ex unit for their fixed width text inputs.

What does this change?

  • Use ex instead of ch to declare text input widths

Screenshots

Before IE11

Screenshot 2020-05-20 at 15 21 30

Before Safari

Screenshot 2020-05-20 at 15 22 25

After IE11

Screenshot 2020-05-20 at 15 20 45

After Safari

Screenshot 2020-05-20 at 15 21 47

Checklist

Accessibility

Cross browser and device testing

  • Tested with touch screen device

Responsiveness

  • Tested at all breakpoints
  • Tested with with long text
  • Stretched to fill a wide container

@probot-autolabeler probot-autolabeler bot added the Text input Changes to the text input component label May 20, 2020
@SiAdcock SiAdcock marked this pull request as ready for review May 20, 2020 14:26
@SiAdcock SiAdcock merged commit 3b095fb into master May 20, 2020
@SiAdcock SiAdcock deleted the sa-text-input-widths branch May 20, 2020 14:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Text input Changes to the text input component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant