[Datepicker] Add a check to fetch current system date#3656
Merged
oliviertassinari merged 1 commit intomui:masterfrom Mar 12, 2016
Merged
[Datepicker] Add a check to fetch current system date#3656oliviertassinari merged 1 commit intomui:masterfrom
oliviertassinari merged 1 commit intomui:masterfrom
Conversation
ed159c2 to
6d8a952
Compare
| }, this.refs.dialogWindow.show); | ||
| } else { | ||
| this.setState({ | ||
| dialogDate: new Date(), |
Contributor
There was a problem hiding this comment.
Since we have this, do we still need new Date() in getInitialState() ?
Contributor
Author
There was a problem hiding this comment.
@nathanmarks : good point. I think we can remove it. Let me do the changes and check
Contributor
|
@tintin1343 I think we can remove that date construction in |
6d8a952 to
d7292a0
Compare
Contributor
Author
|
@nathanmarks : Done. The date attribute is not needed in the getInitialState() method |
| getInitialState() { | ||
| return { | ||
| date: this._isControlled() ? this._getControlledDate() : this.props.defaultDate, | ||
| dialogDate: new Date(), |
Contributor
Author
There was a problem hiding this comment.
U wanted me to remove the dialogDate? But even removing the earlier statement didn't make.any difference.
d7292a0 to
5847f99
Compare
Contributor
Author
|
@nathanmarks : Made the necessary changes. 😅 |
Added a check which helps pick the current system date when the date-picker dialog is opened. Resolves mui#3545
Member
|
LGTM |
oliviertassinari
added a commit
that referenced
this pull request
Mar 12, 2016
[Datepicker] Add a check to fetch current system date
Member
|
@tintin1343 Thanks! |
Contributor
Author
|
@oliviertassinari : Thanks! |
This was referenced Aug 19, 2021
This was referenced Sep 12, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tests/ docs demo, and is linted.The current issue #3545 deals with the date picker not picking up the updated system date when the dialog opens. This happens because if the system date updates but the page is not refreshed then the date which the dialog box gets is the old system date as the system date is set in the getinitialState() of the date picker and is not updated on the system date change.
I observed that there is no check when the openDialog() to get the updated date, which is what I added. I check if the Datepicker has a pre-existing selected date , if it does show that date on openDialog() else if the Datepicker is empty pick up the current system date (this will always pick up the updated date) and hence solves the problem.
Heres the example:

Fixes #3545.