Custom DateRangePicker Dropdown is not working as expected. #275
-
Some context, I want to have a option called const dateRangePickerDropdown = [
{
value: 'tm',
text: 'This month',
startDate: startOfMonth(startOfToday()),
}
];
// Here is how component looks like
<DateRangePicker
defaultValue={[new Date(dateObj.start), new Date(dateObj.end), dateObj.dropdown]}
onValueChange={(value) => {
const [startDate, endDate, dropdown] = value;
setDateObj({
end: format(new Date(endDate), 'yyyy-MM-dd'),
start: format(new Date(startDate), 'yyyy-MM-dd'),
dropdown,
});
}}
enableDropdown={true}
placeholder='Select a date'
enableYearPagination={true}
maxWidth='max-w-xs'
marginTop='mt-0'
color='blue'
options={dateRangePickerDropdown}
/> When selecting {
dropdown: "tm",
end : "2023-01-31",
start: "2023-01-01"
} But date values in the calendar widget are not set correctly. It should set the start as I looked into the code a bit, there is a condition that I think is in-correct in //because this, enddate is not set correctly
if (selectedDropdownValue) {
endDate = startOfToday();
} Let me if I got it wrong or there is way to fix this? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
hey @gokulkrishh, sorry if this is not clear but the dropdown is meant to be used for relative date ranges. Meaning that you provide a |
Beta Was this translation helpful? Give feedback.
-
@mitrotasios I see, got it. Looking forward to endDate option when its available, otherwise loving the library. Keep up the good work 🔥 |
Beta Was this translation helpful? Give feedback.
-
hey @gokulkrishh, JFYI the new |
Beta Was this translation helpful? Give feedback.
-
@mitrotasios Thats Awesome! 💯. One more feedbacks i would like to give is having a chart loader animation for charts. As of now loading of charts without data like BarChart shows empty data. It would be great to have some kind of animation for loading as well like bool prop . |
Beta Was this translation helpful? Give feedback.
-
Is this customization still available, I want to customize dropdown options couldn't find a way to do it |
Beta Was this translation helpful? Give feedback.
hey @gokulkrishh, sorry if this is not clear but the dropdown is meant to be used for relative date ranges. Meaning that you provide a
startDate
in your options as you did, and theDateRangePicker
will set the state to that providedstartDate
and use today's date as anendDate
when that relative dropdown option is selected. We are considering adding anendDate
property to the options as well, so that you have full control basically. Let me know what you think and if you have any other questions :)