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

USWDS: Date Picker - Update month-label width for mobile #4770

Merged
merged 4 commits into from Jun 17, 2022

Conversation

amyleadem
Copy link
Contributor

@amyleadem amyleadem commented Jun 6, 2022

Description

Closes #4761

Preview link: Date picker component

Problem:

The date picker component can experience visual breaks with long month names like November and September when the window width is <320px. This problem is exacerbated by putting the field group in an error state, which adds another rem or so of left padding.

In real-life usage, this means that the date picker needs to support a width of about 224-256px.

Date picker display breaks at very narrow widths

Solution:

By setting the month label to be full width and ordering it so that it lives above the navigation buttons (rather than in-between) we no longer see these visual breaks in the calendar at mobile (<320px) widths.

Testing:

To test,

  1. Open the date picker component and use devTools to reset the dimensions of the window to 224px, 319px, and 320px.
  2. Check for line breaks in the month and year, especially with longer names like "September"

Solution screenshots:

224px:
image

319px:
image

320px:
image

224px with error state:
image

320px with error state:
image

Additional information

Before you hit Submit, make sure you’ve done whichever of these applies to you:

  • Follow the 18F Front End Coding Style Guide and Accessibility Guide.
  • Run npm test and make sure the tests for the files you have changed have passed.
  • Run your code through HTML_CodeSniffer and make sure it’s error free.
  • Title your pull request using this format: [Website] - [UI component]: Brief statement describing what this pull request solves.

@amyleadem amyleadem marked this pull request as ready for review June 6, 2022 17:11
@mahoneycm
Copy link
Contributor

Looks and works great in my testing!

Should we consider adding some styling to the month/year selection menu to make it cleaner/easier to read? Or are they fine as is?

image

image

@amyleadem
Copy link
Contributor Author

Should we consider adding some styling to the month/year selection menu to make it cleaner/easier to read?

@mahoneycm I added some styling to .usa-date-picker__calendar__month-picker for mobile (<320px) that stacks all of the months. I didn't change the years menu because it held up well enough at most narrow widths, and the cost was higher to change the formatting. I don't love the scroll height of the months dropdown, but it was the best I could do without changing the markup.

image

Copy link
Member

@thisisdano thisisdano left a comment

Choose a reason for hiding this comment

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

:chefs-kiss:

@thisisdano thisisdano merged commit 7a5db34 into develop Jun 17, 2022
@thisisdano thisisdano deleted the al-date-picker-month branch June 17, 2022 19:18
@thisisdano thisisdano mentioned this pull request Jun 17, 2022
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.

Date picker may break with long month names at 320px width
4 participants