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] allow year selecton to be open before month/day selection #6420
Conversation
Given this prop only has two options, it might make more sense to make it a boolean. |
@mbrookes I was wondering: #4949 (comment) |
src/DatePicker/Calendar.spec.js
Outdated
|
||
assert.strictEqual(wrapper.find(CalendarMonth).length, 1, 'should have the calendar month select'); | ||
}); | ||
it('should display the year pick view when initialView is set to year', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing blank line
src/DatePicker/Calendar.spec.js
Outdated
@@ -223,4 +225,28 @@ describe('<Calendar />', () => { | |||
assert.strictEqual(wrapper.props().style.width, 310, 'should not allow space for date display'); | |||
}); | |||
}); | |||
|
|||
describe('Initial State', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use description starting with a lower case. It's simply a convention.
@oliviertassinari I see your comment, and the one you replied to, but not any supporting argument. A boolean prop would allow |
@mbrookes having an enum could allow for more than two options in the future, for example if a view for selecting the month was introduced. |
@3upzorz Not going to happen. 😄 (Not on |
@mbrookes @oliviertassinari so should I change to match the boolean approach? |
Pick what @mbrookes think is best, his point is valid 👍. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, aside from using a boolean over an enum, I think that we should be
- using the context to propagate the value
- making is controllable (stateless) instead of impacting the original state then having no more control on the value.
I can change to use a boolean prop, but I don't know about these two points. Maybe I'm missing something? It would be great if you could provide some more clarification on your points or some guidance on how to implement your suggestions. |
@3upzorz I was suggesting using the context as we have to pass the property from parent component to child component multiple times. Yes, that would be the first introduction of the context for that component. Hence, we would break consistency. That's just a suggestion, I think that we should use it in the rewrite on the
Because it's providing more flexibility. If my memory is correct, we have an issue where someone is asking for it. But I could be wrong. Extra flexibility for use cases that don't exist also means more complexity. Let me check that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small comment. I haven't tested the code locally but that looks good otherwise 👍 .
src/DatePicker/DatePicker.js
Outdated
@@ -119,6 +119,10 @@ class DatePicker extends Component { | |||
*/ | |||
onTouchTap: PropTypes.func, | |||
/** | |||
* If true sets the datepicker to open to year selection first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing point at the end of the description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still needs to be fixed.
@oliviertassinari so what's the status of this PR? Any plans to merge it? |
@@ -4,12 +4,14 @@ import DatePicker from 'material-ui/DatePicker'; | |||
/** | |||
* The Date Picker defaults to a portrait dialog. The `mode` property can be set to `landscape`. | |||
* You can also disable the Dialog passing `true` to the `disabled` property. | |||
* To display the year selection first, set the `initialView` property to "year". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please can you update this wording?
I have a small concern regarding usability: if you click a year, it switches to the month/day view, but if you accept the current year with "OK" it closes the dialog; you need to know to click the date in the DateDisplay to switch to date input. Not sure if that's a topic for this or a separate PR? |
@mbrookes seems like a topic for a separate PR. That's more a question of, do you want the OK button's behaviour to change across different views that are displayed. |
@3upzorz That sounds like a good use case for a controlled property that show or hide the year mode. So I think that it's linked to that PR. User could either want to change the view at the year selection event or at the presse OK button event. What do you think? |
@oliviertassinari What is the use case for being able to set this as a controlled property? Having to control this property manually would make the component more painful to use as you would essentially have to handle part of the state of this component in your own application. |
The use case is what @mbrookes suggested. You might want to implement a custom view display logic. My only concern is around, does user have access to the event to actually control the property? Does they know when the year is clicked, when the OK button is clicked, when a year is selected?
Isn't the whole point of overriding the default behavior? If you do so, you have the responsibility to make it better. |
I'm closing the PR has as been inactive for quite some time. |
Has this feature now been implemented or not? I have a case which requests me to either style the "Year" to be highlighted or start the year mode by default. |
@davidhantson It hasn't been implemented. |
The DatePicker component does not have the ability to open the year selection by default, this PR allows a user to specify an attribute to allow the DatePicker to open to year by default.
Closes #4949