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

[BUG] DatePickerRange popup calendar additional date avaliable even with min/max date specified #2910

Open
ForsakenRei opened this issue Jul 2, 2024 · 0 comments
Assignees

Comments

@ForsakenRei
Copy link

Thank you so much for helping improve the quality of Dash!

We do our best to catch bugs during the release process, but we rely on your help to find the ones that slip through.

Describe your context
Please provide us your environment, so we can easily reproduce the issue.

  • replace the result of pip list | grep dash below
dash                 2.17.1
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table           5.0.0
  • if frontend related, tell us your Browser, Version and OS

    • OS: Oracle Linux 9 with Python 3.12
    • Browser Chrome
    • Version 126

Describe the bug

When using DatePickerRange with min_date_allowed and max_date_allowed, choosing a date for start date, there will be one more day after the max date displayed as available but not really selectable.

Expected behavior

Nothing should be available outside of the min_date_allowed and max_date_allowed range?

Screenshots

If applicable, add screenshots or screen recording to help explain your problem.
image
image

Here's the minimum code to reproduce it.

from datetime import date
from dash import Dash, dcc, html, Input, Output, callback

app = Dash(__name__)
app.layout = html.Div([
    dcc.DatePickerRange(
        id='my-date-picker-range',
        min_date_allowed=date(2024, 6, 1),
        max_date_allowed=date(2024, 6, 15),
        initial_visible_month=date(2024, 6, 1),
        end_date=date(2024, 6, 15),
        minimum_nights=0
    ),
    html.Div(id='output-container-date-picker-range')
])


@callback(
    Output('output-container-date-picker-range', 'children'),
    Input('my-date-picker-range', 'start_date'),
    Input('my-date-picker-range', 'end_date'))
def update_output(start_date, end_date):
    string_prefix = 'You have selected: '
    if start_date is not None:
        start_date_object = date.fromisoformat(start_date)
        start_date_string = start_date_object.strftime('%B %d, %Y')
        string_prefix = string_prefix + 'Start Date: ' + start_date_string + ' | '
    if end_date is not None:
        end_date_object = date.fromisoformat(end_date)
        end_date_string = end_date_object.strftime('%B %d, %Y')
        string_prefix = string_prefix + 'End Date: ' + end_date_string
    if len(string_prefix) == len('You have selected: '):
        return 'Select a date to see it displayed here'
    else:
        return string_prefix


if __name__ == '__main__':
    app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants