-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
DayPicker height incorrectly set if element is hidden when rendered #46
Comments
The picker has no way of knowing when the container is suddenly made visible - the proper fix is indeed to only render the picker when it's going to be visible. |
Right - but it'd surely be better, if possible, to adjust the height based on the component state and not the DOM, or to find a way to avoid explicitly setting the height altogether? |
I don't know of any way to avoid that browser limitation here. |
i'm seeing the same issue, but i don't have however, i noticed that the height is correctly adjusted when clicking prev/next months. could the daterangepicker adjust height when start/end date is selected, i.e. when at render: after clicking next: |
let me know if that makes sense, and i'll make a PR! |
Hi @jonathanong! That's surprising that you are seeing height issues without As for the original problem, @donaldharvey I think that maybe once we have some sort of inline-style implementation where we can set the calendar day height and other details as props, we would be able to do the height calculation without reaching into the DOM. Unfortunately, we are not quite there yet. |
@majapw i'm not sure how to give you my setup without giving you my entire app. this issue does not happen in production as i use webpack with extracttextplugin (i.e. it is written to CSS). if i do not use extracttextplugin, webpack injects styles via javascript and inline blobs, which i think causes the issue. |
I have the same issue with webpack. I can produce this issue when I have this in the same file:
And I think @jonathanong is right. Maybe when css style is imported in js file, it takes some time to apply this css to browser. And DateRangePicker starts render before all it styles are applied.
|
Having the same problem: The initial height is like on the screenshot from @jonathanong. I am solving this, defering the rendring of my component using class DateRangeInput {
componentDidMount() {
setTimeout(() => {
this.setState({
activated: true
});
});
}
render() {
<div>
{this.state.activated && <DateRangePicker />}
</div>
}
} I know it is kind of bad practice setting the state within |
I've been thinking more about this problem, and I think that conceivably using the |
This should be fixed in v4.1.1 I think so I'm going to close. @donaldharvey @jonathanong @infernalmaster @davincho please check it out and let me know if this is not the case! |
@majapw yes now everything works smoothly :) |
👆 same |
I'm using
DateRangePicker
, and the container I rendered it in haddisplay:none
initially. This meant that whenadjustDayPickerHeight()
was called, the calculated height was very small. When the container was then shown, the day picker retained this initial height and didn't function correctly.For now I've just made the component render when the container is shown, but it'd be good if this workaround wasn't necessary :)
The text was updated successfully, but these errors were encountered: