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

datepicker doesn't open if date values are `None` #115

Open
chriddyp opened this issue Nov 23, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@chriddyp
Copy link
Member

commented Nov 23, 2017

Originally reported in https://community.plot.ly/t/datepickerrange-clearable-in-tabs-not-working-as-expected/6850/4

import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
from datetime import datetime as dtime

app = dash.Dash()


app.config['suppress_callback_exceptions'] = True
app.layout = html.Div([
    dcc.DatePickerRange(
        id='Dr1',
        clearable=True,
        reopen_calendar_on_clear=True,
        start_date_placeholder_text='Select a date',
        end_date=dtime.today().strftime("%Y-%m-%d")
    ),
    html.Div(id='output')
])


@app.callback(
    Output('output', 'children'),
    [Input('Dr1', 'start_date'),
     Input('Dr1', 'end_date')])
def dates_selected(start_date, end_date):
    value = "From- %s  To-   %s" % (start_date, end_date)
    return value


if __name__ == '__main__':
    app.run_server(debug=True)

Quite a few error messages in the console
image

@xblad

This comment has been minimized.

Copy link

commented May 14, 2018

@chriddyp
Hi Chris, I think the issue above is related to the fact, that DatePickerRange's attribute initial_visible_month isn't defined. Maybe the default value could be set (e.g. datetime.today()) and it would solve the issue (AirBnB's date-picker shows current month by default as well).

xblad added a commit to xblad/dash-core-components that referenced this issue May 16, 2018

Add current date as the initial visible month
Added current date as the last resort for initialVisibleMonth in DatePickerRange.react.js (issue plotly#115)

xblad added a commit to xblad/dash-core-components that referenced this issue May 16, 2018

Add current date as the initial visible month
Added current date as the last resort for initialVisibleMonth in DatePickerSingle.react.js (issue plotly#115)

xblad added a commit to xblad/dash-core-components that referenced this issue May 16, 2018

Add current date as the initial visible month
Added current date as the last resort for initialVisibleMonth in DatePickerSingle.react.js (issue plotly#115)

xblad added a commit to xblad/dash-core-components that referenced this issue May 22, 2018

Fix for datepicker initial month
Added current date as the last resort for the initialVisibleMonth property of the component in DatePickerRange.react.js and in DatePickerSingle.react.js (issue plotly#115)

xblad added a commit to xblad/dash-core-components that referenced this issue May 22, 2018

Fix for datepicker initial month
Added current date as the last resort for the initialVisibleMonth property of the component in DatePickerRange.react.js and in DatePickerSingle.react.js (issue plotly#115)

valentijnnieman added a commit that referenced this issue Nov 21, 2018

Fix merge conflicts in PR-201 (#383)
* Fix for datepicker initial month

Added current date as the last resort for the initialVisibleMonth property of the component in DatePickerRange.react.js and in DatePickerSingle.react.js (issue #115)

* Fix formatting

* Fix DatePickerSingle formatting
@90debasish

This comment has been minimized.

Copy link

commented Feb 27, 2019

Hi Chris,

in the above example what i am facing issue is :

  1. In the beginning when the date picker starts it prints as None- This is completley ok
  2. However when you select some date and then let say clear those dates then it still shows the previous value but it should show as None since the dates are clear.

The problem with the initial approach is:

  1. Let say we selected some date from and end; we get the data from those period- This is completley ok
  2. However let say if we want only data which is less than the end period after previous selection.-------> here we are not able to do so since we still have from value which still has the previous value even if we clear it in the date picker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.