-
Notifications
You must be signed in to change notification settings - Fork 130
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
Refresh date picker components #537
Comments
What about using something like https://github.com/gpbl/react-day-picker? This way we would get rid of external dependencies as well. |
@marielakas You indicated that you're interested in tackling this issue. Is this still the case? Do you have an estimate when you'll be able to work on it? |
I've done some research on third-party calendar libraries and the native date input. Criteria
Ideally, the library should have an intuitive and flexible API though Circuit UI can add an abstraction on top. ComparisonUpdate (April 16, 2024): I've added an updated version of this table below. Ranked by popularity based on weekly NPM downloads
ConclusionOnly two options meet all criteria: The native date input is the simplest, most performant, most accessible solution since it shifts the responsibility of rendering the datepicker to the browser. Unfortunately, it's not yet supported by Safari on macOS where it gracefully degrades to a simple text input. Further, it only works for selecting single dates. Date ranges, disabled dates, etc. are not supported. This advanced functionality requires a custom datepicker. Despite having the lowest number of downloads, An important consideration here is the date library that's used by a calendar library. Aside from Update (February 9, 2021): Turns out |
@connor-baerThanks for considering DayPicker in your list! Just an head up – the next version of Also we will give an extensive look at a11y before the release: follow gpbl/react-day-picker#1036). |
Thanks for reaching out, @gpbl!
I'll do a more thorough review of the accessibility of |
Perhaps another option could be this date picker from Duet's web components design system. It has a strong focus on accessibility (there was even an audit), has a fantastic README and it could be easily wrapped to expose a React component in Circuit. The main downside is that it doesn't support date ranges in a single visual element (there was a feature request for it: duetds/date-picker#61). A workaround is to use two separate inputs for selecting ranges: duetds/date-picker#4 (comment) but this may not be enough to cover all our use cases. |
As I see you're mentionning the native const DatePicker = () => {
const [hasJS, setJS] = useState(false)
useEffect(() => setJS(true))
if(!hasJS) return (
<input type="date" />
)
return (
your beloved work
)
} of course, with all the attributes an accessible app need... that can be a nice pattern everytime we do something relying too much on JS. |
@long-lazuli What problem are you trying to solve with this approach? If you're trying to avoid JavaScript bloat, you'd need to code-split the custom date picker by dynamically importing it. This is difficult to do at the design-system-level since we can't make assumptions about the bundler that's gonna be used and whether it supports dynamic imports. Therefore we leave such optimizations to be implemented in userland. |
I'm jotting down some thoughts here because I've done a bit of research related to date in forms yesterday: What date picker components do we need?Moving forward, we'll want to have (at least) three date input components:
Here's the rationale for that, along with extra thoughts:
Date inputOur current DateInput component is a styled wrapper around the native IssuesAlthough it can seem that using the platform™️ is a good choice here, the native date input has a few issues that make us reluctant to use it:
ImprovementsI would recommend creating a new input component wrapping a default text field, and simply formatting the date much like our A designer created a POC for it (mind the UX primarily): https://jsfiddle.net/vabe284o/3/ Further accessibility testing will be required, but we would ideally like:
If there are no concerns here, we will start working on the implementation for this next quarter (designs will be ready by then), which should eventually replace our current Calendar input componentsThe calendar input components will likely reach for a third-party library, since we want to avoid writing the implementation ourselves. @connor-baer did excellent research on these. I haven't looked much into them (yet), and we don't have the capacity to tackle it right now, since this is a larger change than the Here are some extra resources for consideration when we look into it again:
|
|
Adobe just released a fully accessible and customizable range of date picker components: https://react-spectrum.adobe.com/blog/date-and-time-pickers-for-all.html Edit: accessibility review |
What would be great is to allow this component to be an abstraction of two uncontrolled inputs. So we could use |
@connor-baer I was thinking of tackling this as a hack day project... react-dates has to go. Any specs to follow or should I just try my best to copy what we have already? |
That's awesome @fernandofleury! No specs really, there's a WIP new design for the calendar picker (Figma internal link) but it needs review (and doesn't cover all existing use cases). if you replicate the API one-to-one we can ship it with minimal migration effort. Otherwise, we can also look into usage (CodeSearch is really good) and see if we want to drop any component/variant/option. Did you have any rough idea of a replacement library? Did you want to tackle everything that uses |
@robinmetral I think the first step is replacing I'll first try it out with react-date-picker. Even though the spectrum one doesn't look back, I'd rather rely on |
I explored using Would you like to continue with my proof of concept, @fernandofleury? |
The design system team has started work on new date and date range input components. The original review of third-party calendar libraries is over 3 years old, so I've updated it below. I've added another criterium:
As much as I want to start moving towards web components, React's lack of compatibility would make the integration of
This leaves Edit: Added |
Hi @connor-baer, we indeed have 2 known accessibility issues with react-day-picker. gpbl/react-day-picker#1688 is being addressed via gpbl/react-day-picker#2089 and will be fixed in the upcoming major release. Keep in mind in your evaluation that DayPicker requires some performance optimization. The CSS need to be simplified. The TypeScript declarations need some refresh... I'm addressing these issues in my spare time. However, they are time-consuming as they necessitate rewriting most of the code. I would greatly appreciate any help with DayPicker! While it's exciting to see my work help other developers, it also comes with external pressures that can be challenging to manage. Hopefully adding more docs about the architecture and the DayPicker roadmap will help get more contributors... |
Thanks for reaching out, @gpbl! Your responsiveness is exemplary and I appreciate all the effort you've put into I started a proof-of-concept using
In the end, I found that implementing the calendar from scratch using the |
Components to amend
Calendar, CalendarTag, CalendarTagTwoStep, RangePicker, SingleDayPicker
Context
Circuit UI contains a bunch of similar and confusingly named date components right now.
Tasks
react-dates
with a library that supports TypeScript, tree-shaking, and doesn't depend onmoment.js
The text was updated successfully, but these errors were encountered: