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

[DateRangePicker] Day component not supporting DateRange some props #4566

Closed
2 tasks done
bneigher opened this issue Jul 15, 2020 · 5 comments
Closed
2 tasks done

[DateRangePicker] Day component not supporting DateRange some props #4566

bneigher opened this issue Jul 15, 2020 · 5 comments
Labels
component: DateRangePicker The React component. component: pickers This is the name of the generic UI component, not the React module! new feature New feature or request plan: Pro Impact at least one Pro user

Comments

@bneigher
Copy link

I'm implementing a custom Day UI to live in the DateRange picker. It looks like this:
Screen Shot 2020-07-15 at 12 29 42 PM
You can see that in this date range, none of the IN RANGE days are highlighted, which is odd.
I'm seeing some errors in the console:

React does not recognize the `isEndOfHighlighting` prop on a DOM element
React does not recognize the `isStartOfHighlighting` prop on a DOM element.
React does not recognize the `isHighlighting` prop on a DOM element.
React does not recognize the `isEndOfPreviewing` prop on a DOM element.
React does not recognize the `isStartOfPreviewing` prop on a DOM element.
React does not recognize the `isPreviewing` prop on a DOM element.

Which leads me to believe that some of the date range props are not supported in the Day component.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Day component not rendering isHighlighting days in the date range

Expected Behavior 🤔

Day range should render highlighted zone correctly as it does without specifying the custom renderDay method:
Screen Shot 2020-07-15 at 12 35 12 PM

Here is a simplified version of a renderDay with shows issue

const renderDayInPicker = (day, dateProps) => {
	return <Day {...dateProps} />
}

Steps to Reproduce 🕹

https://codesandbox.io/s/headless-sun-ig04d

Your Environment 🌎

Tech Version
@material-ui/core v4.11.0
@material-ui/pickers v4.0.0-alpha.9
React 16.13.1
Browser Chrome
TypeScript no
@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 21, 2020

@bneigher Awesome feedback, thanks for raising. I have updated your codesandbox to work with the latest version: https://codesandbox.io/s/strange-dirac-pcplh. We have started to surface the problem in mui/material-ui-pickers#2006.

We have two different components internally PickersDay and PickersDayRange, and yet we have the same prop renderDay API with two different API between a DatePicker and DateRangePicker. This is confusing.

I think that we should differentiate the two. I believe the RFC in: mui/material-ui#21453 will solve this problem.

<DateRangePicker components={{ Day: PickersDay, DayRange: PickersDayRange }}

So that @bneigher can use the same custom PickersDay component between day and day ranges.

@MirkoTV
Copy link

MirkoTV commented Nov 5, 2020

Any progress on this one? I couldn't either import PickersDayRange. Looks like we do not expose that:

import { PickersDayRange } from '@material-ui/pickers';
Not works :)

I noticed this is tagged for v5 but is there a chance we could just expose PickersDayRange in the library for now? I think that would help a lot at least for minor customizations like basic css. Right now I am really blocked by this one, and I would just like to add background to some specific days

I am using 4.0.0-alpha.12 version of the lib

Thanks a lot for the excellent library btw!

@leolozes
Copy link

leolozes commented Dec 2, 2020

I am facing the same issue, I want to add some custom elements to the calendar days, but without messing with the selection (which is awesome BTW).
I tried to find the code to replicate the selection behaviour (kind of like the one that is in the docs of the Customized day rendering), but no luck either.

I'm using the lab version v5.0.0-alpha.17, and getting the same warnings as @bneigher.

Keep up the great work and thank you for providing us with this awesome library!

@oliviertassinari oliviertassinari changed the title Day component not supporting DateRange some props [DateRangePicker] Day component not supporting DateRange some props Dec 2, 2020
@oliviertassinari oliviertassinari transferred this issue from mui/material-ui-pickers Dec 2, 2020
@oliviertassinari oliviertassinari added the component: DateRangePicker The React component. label Dec 2, 2020
@cherniavskii cherniavskii transferred this issue from mui/material-ui Apr 18, 2022
@cherniavskii cherniavskii added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 18, 2022
@cherniavskii
Copy link
Member

Still an issue with @mui/x-date-pickers-pro: https://codesandbox.io/s/ancient-silence-zmpd5p?file=/package.json

@cherniavskii cherniavskii added new feature New feature or request component: pickers This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Apr 20, 2022
@joserodolfofreitas joserodolfofreitas added the plan: Pro Impact at least one Pro user label Apr 25, 2022
@m4theushw
Copy link
Member

m4theushw commented Apr 25, 2022

The component used to render days inside DateRangePicker can now be imported as DateRangePickerDay:

import { DateRangePickerDay } from '@mui/x-date-pickers-pro';

CodeSandbox: https://codesandbox.io/s/ancient-silence-zmpd5p?file=/src/demo.jsx

Docs: https://mui.com/x/react-date-pickers/date-range-picker/#customized-day-rendering

We plan to migrate the API to a slot approach, same as the DataGrid, so I'll close this one in favor of #4466

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: DateRangePicker The React component. component: pickers This is the name of the generic UI component, not the React module! new feature New feature or request plan: Pro Impact at least one Pro user
Projects
None yet
Development

No branches or pull requests

7 participants