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

Add max-width to file upload #2306

Merged
merged 2 commits into from
Aug 26, 2021
Merged

Add max-width to file upload #2306

merged 2 commits into from
Aug 26, 2021

Conversation

CharlotteDowns
Copy link
Contributor

@CharlotteDowns CharlotteDowns commented Aug 11, 2021

What we've changed

This PR adds a width attribute to the file-upload component.

Fixes #2007 .

Why we've changed it

When a user magnifies to 400% zoom the component does not resize to fit the viewport and horizontal scrolling appears.

Before / After

Chrome, MacOS

Screenshot 2021-08-23 at 15 07 36Screenshot 2021-08-23 at 15 07 45

Safari, MacOS

Note: Safari Zoom doesn’t seem to go to as high a zoom level as Chrome so you don’t normally see the issue even on the ‘before’ when zooming to max. However, it's possible to replicate the issue by zooming to max and also making the Safari window narrower, as if on a tablet.

Screenshot 2021-08-23 at 15 11 50Screenshot 2021-08-23 at 15 11 56

Firefox, MacOS

Screenshot 2021-08-23 at 15 14 55Screenshot 2021-08-23 at 15 14 49

IE11

Note: ignore the floating browserstack menu!
Screenshot 2021-08-23 at 15 17 20Screenshot 2021-08-23 at 15 17 36

IE10

Note: ignore the floating browserstack menu!
Screenshot 2021-08-23 at 15 19 50Screenshot 2021-08-23 at 15 20 06

IE9

Note: ignore the floating browserstack menu!
Screenshot 2021-08-23 at 15 21 42Screenshot 2021-08-23 at 15 21 55

IE8

Note: ignore the floating browserstack menu! Change doesn't seem to have any effect in IE8. Not sure what’s going on with the zooming here, IE8 zooming seems to take the content off the left side of the screen, but this happens in both versions so not a result of this change.

Screenshot 2021-08-23 at 15 23 34

Screenshot 2021-08-23 at 15 23 50

@CharlotteDowns CharlotteDowns changed the title add width to file upload Add width to file upload Aug 11, 2021
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2306 August 11, 2021 09:44 Inactive
@vanitabarrett
Copy link
Contributor

@CharlotteDowns Is it intentional that we're making the file upload component always full width now, so it'll take up the full width of the container it's placed in? This does seem to match what we do for the text input component, but I know Ollie's original comment in the backlog seems to imply that's something we might not want to do for the file upload component.

Example at default zoom on desktop the focus area for the component now looks like this:

Screenshot 2021-08-11 at 13 26 58

Whereas before it looked like this:

Screenshot 2021-08-11 at 13 37 27

@CharlotteDowns
Copy link
Contributor Author

@vanitabarrett I had the same concern.

I'll do some further investigation work around the original width and the other implications of making the file-upload component 100% width.

@36degrees
Copy link
Contributor

Bear in mind the file upload input type is displayed very differently across different browsers and operating systems. I think we'd want to test this pretty thoroughly across all of our supported combinations to be sure. Ideally it'd be good to get before/after screenshots for all of them.

Most of our other form inputs will grow to fill the available space, so I can see the argument for doing the same here. Aside from the way the focus state displays, it also means there can be quite a lot of invisible 'clickable area' in some browsers – which might also be an issue on mobile when scrolling?

(Now it's been pointed out, I've no idea why the file upload in Chrome doesn't shrink to tightly wrap the button and filename label – I've no idea why it's the width it is.)

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2306 August 17, 2021 12:18 Inactive
@CharlotteDowns
Copy link
Contributor Author

CharlotteDowns commented Aug 25, 2021

Testing across browsers, before and after

We've had a look into the before behaviour of the focused file upload component compared with the focused file upload component at max-width: 100%.

On Chrome version 92.0.4515.159 without max-width the component requires right scrolling
Screenshot of file-upload on chrome version 92.0.4515.159 without max-width

On Chrome version 92.0.4515.159 with max-width the component is contained within the width of the browser size Screenshot of file-upload on chrome version 92.0.4515.159 with max-width

More examples

Examples across the other browsers that we support can be found in this slide deck.

We also compared the form elements page in the GOV.UK Frontend review app before and after to see how the behaviour compares to the other form field components we have in the Design System.

Takeaways

The change to add max-width seems to test well with 400% zoom across the browsers we support. IE8 seems to take content off the left of the screen which at the moment we are not sure why.

@vanitabarrett
Copy link
Contributor

@36degrees Updated the PR description with those screenshots now

@36degrees
Copy link
Contributor

Looks good, thanks 🙂 Just needs a changelog entry I think?

@CharlotteDowns CharlotteDowns changed the title Add width to file upload Add max-width to file upload Aug 26, 2021
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2306 August 26, 2021 09:32 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2306 August 26, 2021 09:36 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2306 August 26, 2021 12:46 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2306 August 26, 2021 12:47 Inactive
Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@CharlotteDowns CharlotteDowns merged commit 2a7b638 into main Aug 26, 2021
@CharlotteDowns CharlotteDowns deleted the add-width-to-file-upload branch August 26, 2021 13:16
@EoinShaughnessy EoinShaughnessy changed the title Add max-width to file upload Add max-width to file upload Aug 31, 2021
@vanitabarrett vanitabarrett mentioned this pull request Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File upload component at 400% zoom does not resize
4 participants