plotly / plotly/dash

DatePickerRange popup calendar additional date avaliable even with min/max date specified

Open
#2,910 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3 sev-3
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the DatePickerRange entry point and run the provided minimal Python reproduction using min_date_allowed and max_date_allowed. Confirm the extra date is displayed as available beyond June 15, 2024; done means dates outside the configured range are not presented as available, with regression coverage for the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.