Skip to content
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

DateRangePicker Singe Date Selection Issues #47

Closed
bigmike36c opened this issue Feb 26, 2022 · 5 comments
Closed

DateRangePicker Singe Date Selection Issues #47

bigmike36c opened this issue Feb 26, 2022 · 5 comments

Comments

@bigmike36c
Copy link

Hello,

Really appreciate your work on this awesome project!

I'm having issues selecting a single date with the daterangepicker. The first issue is with the UI as shown below. When trying to select a single date the first time, the selection simply disappears. However, the second time I select a single date, it stays.

Screen.Recording.2022-02-25.at.8.16.47.PM.mov

The second issue is triggering a callback with a single date selection. Can this be done? I was hoping the callback value would be something along the lines of ["selected_start_date", maxDate], but a single selection does not appear to trigger the callback.

Thanks in advance for any help.

@snehilvj
Copy link
Owner

snehilvj commented Mar 1, 2022

Hi @bigmike36c, Thanks for reporting this issue. I agree with your comment about the behaviour and I have corrected that (will be released in 0.6.0).
Regarding your second issue, can you please briefly explain your process? How will you use it if single date selection were to trigger a callback.

snehilvj added a commit that referenced this issue Mar 1, 2022
@bigmike36c
Copy link
Author

Thanks for correcting this so quickly!

In my mind, if a user only selects a single date, then the user expects the date range to extend from the start date to the maximum date available.

The code snippet below is essentially how I've been handling this with the default dcc.DatePickerRange. If the callback is triggered with only one date selected (either start or end), the other date is simply set to an empty string in the callback. I then convert the empty string to the minimum or maximum date in the dataframe.

start_date = start_date or df["datetime"].min()
end_date = end_date or df["datetime"].max()

Since the dmc.DateRangePicker only lets you select the start date on its own, I think it would make the most sense for the callback to receive ["selected_start_date", maxDate]. If the maxDate parameter was not set, it could be replaced with an empty string or None.

@snehilvj
Copy link
Owner

snehilvj commented Mar 5, 2022

Okay got it.
I can think about partial callback where in you at least get one date which is selected (keeping in mind backwards compatibility).
But I don't think we can do

callback to receive ["selected_start_date", maxDate].

It makes the date range picker less intuitive as to what's in the value is not what's displayed, etc.

@bigmike36c
Copy link
Author

Makes sense to me. Could the callback just trigger with "selected_date" as a string instead of a list? This would make it easy to handle both single date and range selections in the callback logic with the isinstance() function.

@snehilvj
Copy link
Owner

snehilvj commented Oct 1, 2022

Ability to select single date won't be supported in dmc.DateRangePicker, for such purposes please use two date pickers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants