-
Notifications
You must be signed in to change notification settings - Fork 19
feat(DateRangePickerInput/web): max range #196
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
base: master
Are you sure you want to change the base?
Conversation
|
Deploy preview for leaf-ui ready! Built with commit 05075eb |
| }), | ||
| format: PropTypes.string, | ||
| minRange: PropTypes.number, | ||
| maxRange: PropTypes.number, |
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.
how about having
range: {
min: 1,
max: Infinity,
}
|
I could see component remounts on this preview. You can check that in the network tab the fonts are being downloaded again and again on every range selection and it triggers a flash as well when you look at the component. Just ensure that it's not netlify which is screwing this up. The stories are broken for |
| this.datePickerHasFocus = false; | ||
| this.timeout = {}; | ||
| this.range = { | ||
| min: this.props.range.min >= 0 ? this.props.range.min : 1, |
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.
I would rather have this in render than here since we should not block props reflow. You can definitely argue that this prop will not change throughout the lifecycle of this component but you can't enforce that on your users/consumers I can have
<DateRangePickerInput
range={{ min: someValueFromState, max: someValueFromState}}
/>
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.
How about this?
makeSelectionRange = (selectionRange) => ({
min: selectionRange.hasOwnProperty('min') ? selectionRange.min : 1,
max: selectionRange.hasOwnProperty('max') ? selectionRange.max : Infinity,
})
and from render you can call this
const selectionRange = makeSelectionRange(this.props.selectionRange)
feat(DateRangePickerInput/web): max range (#196)
| from: PropTypes.bool, | ||
| to: PropTypes.bool, | ||
| }), | ||
| range: PropTypes.shape({ |
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.
also this prop can be renamed to selectionRange because it's too confusing otherwise?
| required: { | ||
| from: false, | ||
| to: false, | ||
| }, |
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.
you can't ignore defaultProps. That's the reason other stories are breaking since they are getting range as undefined in the constructor that's where defaultProps helps you
No description provided.