SingleDatePicker with numberOfMonths={1} not displaying month table
See original GitHub issueI tried to implement the SingleDatePicker wrapped in the same way found in the examples. This is the result:
For some reason the current month table seems to be positioned outside the container. The month previous to the current month (October) is rendered in the position where the current month(November) should be , and is hidden because of the numberOfMonths={1} prop, therefore the white space.
This is how I’ve implemented the wrapper:
import React from 'react';
import { SingleDatePicker } from 'react-dates'
import 'react-dates/lib/css/_datepicker.css'
class SingleDatePickerWrapper extends React.Component {
constructor(props) {
super(props);
this.state = {
focused: false,
date: null,
};
this.onDateChange = this.onDateChange.bind(this);
this.onFocusChange = this.onFocusChange.bind(this);
}
onDateChange(date) {
this.setState({ date });
}
onFocusChange({ focused }) {
this.setState({ focused });
}
render() {
const { focused, date } = this.state;
return (
<SingleDatePicker
{...this.props}
id="date_input"
date={date}
focused={focused}
onDateChange={this.onDateChange}
onFocusChange={this.onFocusChange}
/>
);
}
}
export default SingleDatePickerWrapper;
And this is how I’m using it:
<SingleDatePickerWrapper
numberOfMonths={1}
/>
I’m not sure if I’m doing something wrong or if I need to pass some extra props through the wrapper in order for the component to render correctly, but I’m using it pretty much unchanged from the SingleDatePicker example. Any help would be greatly appreciated 😃
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:8
Top Results From Across the Web
SingleDatePicker with numberOfMonths={1} not displaying ...
For some reason the current month table seems to be positioned outside the container. The month previous to the current month (October) is ......
Read more >Airbnb react date range picker only showing current month ...
After selecting start date and end date when I am re-opening the date picker the calendar shows current month instead of the selected...
Read more ><input type="month"> - HTML: HyperText Markup Language
A Boolean attribute which, if present, means this field cannot be edited by the user. Its value can, however, still be changed from...
Read more >Date Range Picker for Bootstrap
The Date Range Picker can be turned into a single date picker widget with only one calendar. In this example, dropdowns to select...
Read more >Date Range Picker — JavaScript Date & Time Picker Library
* Addition: when set, show only 1 calendar with 1 month even if singleDatePicker is not set. */ singleMonthView?: boolean;. I extracted some...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, I am using the
DayPickerRangeController
component and I am having the same issue as @7091lapS . I cloned the repo and ran the scriptyarn build:css
to retrieve the CSS and copied it into my project. I also tried all the above recommendations to no avail. Here is what my wrapper looks like:Here is what renders:
Any help would be much appreciated 😃
@majapw I believe #256 correctly identifies the source of the problem. The parent container needs to be
text-align: left;
. Thanks.