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

DatePicker month selector not working when minDate in current month #1738

Closed
izziaraffaele opened this issue Sep 27, 2015 · 24 comments
Closed
Labels
component: date picker This is the name of the generic UI component, not the React module! component: pickers This is the name of the generic UI component, not the React module!

Comments

@izziaraffaele
Copy link
Contributor

If the minDate set on the DatePicker is in the current month when I open the DatePicker dialog and I change months, the back button is broken and I cannot go back to the previous month.

schermata 2015-09-27 alle 21 30 13

@yulric
Copy link
Contributor

yulric commented Sep 29, 2015

Yeah I'm seeing this also, I'll take a look at it and try to see what's happening.

@izziaraffaele
Copy link
Contributor Author

It might be related with #1737

@onchainguy-btc
Copy link

+1

1 similar comment
@ansgarm
Copy link

ansgarm commented Sep 29, 2015

+1

@yulric
Copy link
Contributor

yulric commented Sep 30, 2015

So I believe the problem is with the following lines of code https://github.com/callemall/material-ui/blob/master/src/date-picker/calendar.jsx#L263-L264.

The prevMonth and nextMonth fields decide if the buttons next to the current month are enabled or not. If you use this.state.selectedDate then when the selectedDate is before the minDate the prev month button is always disabled. If you use dialogDate instead of selectedDate then the it all works well.

Does that make sense?

@moritzmann
Copy link

+1

@izziaraffaele
Copy link
Contributor Author

Having a fast look at the code I think you should use displayDate if that is the piece of code that controls the month picker.

For what I can understand displayDate is the first day of the current displayed month so calculating the difference with the minDate you can understand if there are other pages to display after/before the current page.

@yulric
Copy link
Contributor

yulric commented Sep 30, 2015

sorry displayDate is right, I don't know why I said dialogDate. I'll start working on this and try to get it done before the weekend.

@shaurya947
Copy link
Contributor

👍 @yulric looking forward to the fix

yulric added a commit to yulric/material-ui that referenced this issue Oct 3, 2015
yulric added a commit to yulric/material-ui that referenced this issue Oct 6, 2015
@yulric
Copy link
Contributor

yulric commented Oct 6, 2015

@shaurya947 Issues have been fixed in PR #1808 and #1796

shaurya947 added a commit that referenced this issue Oct 6, 2015
Issue #1738 with respect to maxDate prop
@shaurya947
Copy link
Contributor

@yulric I have merged #1808. Do we also need #1796?

@yulric
Copy link
Contributor

yulric commented Oct 6, 2015

Yeah, 1796 fixes the minDate issue whereas 1808 fixes the maxDate issue, sorry about that. I'll fix the merge conflicts in 1796.

yulric added a commit to yulric/material-ui that referenced this issue Oct 7, 2015
@yulric
Copy link
Contributor

yulric commented Oct 7, 2015

@shaurya947 I fixed the merge conflicts for PR 1796. It can now be merged into master.

shaurya947 added a commit that referenced this issue Oct 7, 2015
@shaurya947
Copy link
Contributor

Done @yulric!

@izziaraffaele @seb0zz @ansgarm feel free to checkout the latest code from master and see if the issue has been resolved.

@yulric
Copy link
Contributor

yulric commented Oct 7, 2015

thanks @shaurya947

chrismcv pushed a commit to chrismcv/material-ui that referenced this issue Oct 13, 2015
chrismcv pushed a commit to chrismcv/material-ui that referenced this issue Oct 13, 2015
yulric added a commit to yulric/material-ui that referenced this issue Oct 16, 2015
yulric added a commit to yulric/material-ui that referenced this issue Oct 16, 2015
yulric added a commit to yulric/material-ui that referenced this issue Oct 22, 2015
@nathando347
Copy link

Hi guys, is this fixed in v0.12.5 yet? I'm using v0.12.5 and this problem still there.
What's the quick fix for it without forking the whole source base?
Thanks

@yulric
Copy link
Contributor

yulric commented Oct 22, 2015

@nhantamdo this is supposed to be fixed. Can you give the your use case where it's not working? Thanks.

@nathando347
Copy link

Hi yulric,
If set minDate={new Date()}, and nagivate to next month (using > button), the < button still disabled. The only way to enable it was to click on some random date (on that next month page). After that the < button was enabled even for the months it was not supposed to be (months prior to minDate).
Hope this helps,

@yulric
Copy link
Contributor

yulric commented Oct 22, 2015

@nhantamdo When I set the minDate to the current date in the Ranged Date Picker example in the material-ui docs and open the DatePicker it seems to be woking correctly i.e. the previous month button is initially disabled and clicking on the next month button enables it. Could you try it here http://material-ui.com/#/components/date-picker and see if your use case still fails?

@nathando347
Copy link

@yulric I've tried to do exactly as in the example docs but the problem still there. Is the example using the lastest version? (v0.13.0). I'm using version v0.12.5 because meteor haven't updated react to v.0.14.0 yet.
Thanks,

@yulric
Copy link
Contributor

yulric commented Oct 22, 2015

@nhantamdo v0.12.5 has the fix for the issue. Have you made sure that you have v0.12.5? And if you do could you send me a code snippet with the problem so I can debug it on my end? Thanks.

@nathando347
Copy link

@yulric Thanks for your help. The problem was on my end. I updated material-ui to v.0.12.5 yesterday and somehow the old version still cached in meteor build. Great work guys !
BTW, can you shed some light on how to internationalize this DatePicker? I need to support another language.
Many thanks,

@yulric
Copy link
Contributor

yulric commented Oct 22, 2015

No problem. I'm not sure about the internationalize part unfortunately. @shaurya947 would have a better idea.

@shaurya947
Copy link
Contributor

@nhantamdo regarding the internationalization part, @oliviertassinari is leading that effort #1658

@zannager zannager added component: date picker This is the name of the generic UI component, not the React module! component: pickers This is the name of the generic UI component, not the React module! labels Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: date picker This is the name of the generic UI component, not the React module! component: pickers This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

8 participants