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
Date Range using input with clear button Not Working #2959
Comments
I have the same problem as @UnikoveNeeraj But in my component code, displaying the selected range doesn't work. There is also no clear values button. As you can see from the logs, the selected values are perfectly passed through the callback function in the array format. I use "react-datepicker": "3.8.0" and "react": "16.8.4". Me component code: import React from "react";
import PropTypes from "prop-types";
import DatePicker from "react-datepicker";
function DateRangePicker(props) {
const [dateRange, setDateRange] = React.useState([null, null]);
const [startDate, endDate] = dateRange;
/* Logging values */
React.useEffect(() => props.onChange(dateRange), [dateRange]);
return (
<DatePicker
selectsRange={true}
endDate={endDate}
isClearable={true}
startDate={startDate}
onChange={(dates) => setDateRange(dates)}
shouldCloseOnSelect={false}
/>
);
}
DateRangePicker.propTypes = {
onChange: PropTypes.func.isRequired,
};
DateRangePicker.defaultProps = {
};
export default DateRangePicker; |
I am also facing the same issue, on selecting date range its not displaying selected date in Input field. here is the code, we are using https://codesandbox.io/s/blissful-blackwell-bk56e?file=/src/App.js |
I am also facing the same issue (Dates and clear button isn't displayed after selection). Used the same example from the docs. https://reactdatepicker.com/#example-date-range-using-input-with-clear-button As a workaround, am currently using
|
I am experiencing the same issue and had to implement the workaround from @sharanya5 (Thanks!). However I am also experiencing issues with the popper closing when selecting "startDate", and as such I have to open the popper again to select "endDate". I have to set "shouldCloseOnSelect" to false to keep the popper open, but then I have to manually close the popper when selecting "endDate". I expect "shouldCloseOnSelect" should be true and the popper should close only when both "startDate" and "endDate" has been filled? |
I am having exactly this issue. When I select the first date, the calendar closes. It then re-opens to select the second date. The date range does not display in the input field, however. And no clear button shows up. My code is essentially the same as the demo code, except for where I store and retrieve the dates. I'm happy to give details as needed, but the examples above pretty much capture it. |
same issue with the start selection closes the popper.
|
On version function DateRangePicker() {
const [startDate, setStartDate] = React.useState(null);
const [endDate, setEndDate] = React.useState(null);
const onChange = (dates) => {
const [start, end] = dates;
setStartDate(start);
setEndDate(end);
};
return (
<DatePicker
selected={startDate}
onChange={onChange}
startDate={startDate}
endDate={endDate}
selectsRange
isClearable
/>
);
} |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
const [dateRange, setDateRange] = React.useState([null, null]);
const [startDate, endDate] = dateRange;
function updateExecutionList(date): void {
setDateRange(date);
// props.updateExeList(date);
}
<DatePicker
selectsRange={true}
When first date select calender get closed and also slected value is not showing.
any one help if i am doing somthing wrong
The text was updated successfully, but these errors were encountered: