feat(DatePicker): New DatePicker component#3286
Conversation
|
View your CI Pipeline Execution ↗ for commit afaea71 ☁️ Nx Cloud last updated this comment at |
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
LinKCoding
left a comment
There was a problem hiding this comment.
nice start!
I wasn't sure entirely where to hone in for DatePicker related files specifically tbh
but I gave some thoughts for Calendar files.
Something for much later on is to use JSDoc style comments for the util functions
| /** | ||
| * Normalize to start of day in local time for comparison. | ||
| */ |
There was a problem hiding this comment.
Consider converting these comments for functions to JSDoc format
There was a problem hiding this comment.
the robot wrote all of these so maybe we can teach it to write them as jsdocs
| @@ -0,0 +1,122 @@ | |||
| import { | |||
There was a problem hiding this comment.
This is missing a .mdx file
| const [selectedDate, setSelectedDate] = useState<Date | null>(null); | ||
| return ( | ||
| <Box> | ||
| <DatePicker |
There was a problem hiding this comment.
@dreamwasp said they would help look into this
There was a problem hiding this comment.
I'm still reviewing but wanted to get my first set of notes up, so here they are. I haven't looked at the React code yet.
Initial focus
There are two possibly related issues here:
-
Focus shouldn't move into the calendar when I click into the
inputwith a pointer.When I first click into the
inputelement with a pointer (mouse), the calendar opens and focus moves into it. I think it's okay for the calendar to open on click, but focus shouldn't move into it unless the user specifically chooses to move focus into it. As-is, I can't click the input and start typing.Interestingly, if I navigate to the
inputwith a keyboard or screen reader, focus doesn't move into the calendar until I press ArrowDown so I'm guessing this is specifically tied to pointer or mouse events?This is a violation of WCAG 3.2.1 On Focus since focus moves on focus (technically it's probably moving on click, but the effect is the same).
-
When focus does move into the calendar the first time, it should always be visible.
When the date is empty and I open the calendar, I can't tell where focus is. It's okay if focus isn't visible for pointer users after they click around in it—this is just about the initial state on open.
My rationale for this is that the input retains a blue hover indicator that makes it look like it's focused when it's not, which is confusing. Pointer users might expect to switch to using their keyboard when they interact with input fields, so the visual focus indicator is important for everyone here, not just keyboard users.
Note that it's visible when I open it with my keyboard but it's not visible when I open it with my mouse, so I'm guessing this is an artifact of :focus-visible.
Focus ring
The focus ring for the grid cells in the calendar uses what looks like an opacity transition. Generally for grids like this you want to keep motion minimal (including opacity transitions) since it's dense and this can be distracting. I'd recommend nixing the transition for the grid cells.
This isn't a WCAG violation but COGA Usable covers distractions pretty clearly and I always try to look out for this kind of thing.
Grid cell selected state
Currently, it's not possible to discern whether a grid cell is selected or not with a screen reader. After digging into this, I'm not 100% what the best solution to this would be so I'm going to keep digging, but I'll describe the problem and our options at least.
The grid cells (role="gridcell") currently have the following structure:
<td aria-selected={state} role="gridcell">
<button tabindex="0" type="button" />
</td>Since the interactive element is the <button>, screen reader users can't access the aria-selected state while interacting with the buttons (when they need to know it). And we can't move aria-selected to the button because aria-selected isn't valid on buttons.
Given all of that, I think we have two options:
<!-- 1. take the td out of the a11y tree; use the button as our cell -->
<td role="none">
<button aria-selected={state} role="gridcell" tabindex="0" />
</td>
<!-- 2. get rid of the button -->
<td aria-selected={state} role="gridcell" tabindex="0">
{the_day_number}
</td>I don't love option 1 since it feels wrong to override so many semantics like that but it's technically probably okay. I'll keep digging to see if there's a good reason to prefer one of the two choices, or if there are other options.
Placeholder isn't accessible to anyone
The date format is currently only accessible via the input's placeholder. But once I click into it, I can't see it anymore. In other words, when I'm typing my date, I can't see what format the date needs to be in, which is exactly when the format is most important to me.
The only way for a user to solve this problem is to commit the placeholder format to their working memory, a difficult task for everyone and an impossible task for some. WCAG famously doesn't have a success criterion to address this but it is something they're looking to address in WCAG 3. For now, COGA Usable does cover it under Ensure Processes Do Not Rely on Memory.
My recommendation is a controversial one: never use placeholder, for any reason. Use a field description or a static floating label that moves when the input is focused (Material design uses this).
|
@sh0ji re focus ring transition: this is our default gamut focus ring. do you want me to override it for this case or can i cut a separate ticket to update the focus ring opacity transition across the board? |
|
📬 Published Alpha Packages: |
|
🚀 Styleguide deploy preview ready! Preview URL: https://69c181c58e14e711f10747d3--gamut-preview.netlify.app |

Overview
WIP of the new DatePicker component. Looking for some early feedback, comments, questions, concerns. I left some comments in the code of things I'm questioning.
Things I know are missing/not completely working:
PR Checklist
Testing Instructions
Don't make me tap the sign.
PR Links and Envs