Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

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

Closed
chriddyp opened this issue Nov 23, 2017 · 3 comments
Closed

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

chriddyp opened this issue Nov 23, 2017 · 3 comments
Labels
dash-meta-good_first_issue dash-type-bug Something isn't working as intended

Comments

@chriddyp
Copy link
Member

chriddyp 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

@chriddyp chriddyp added dash-type-bug Something isn't working as intended dash-meta-good_first_issue labels Nov 23, 2017
@xblad
Copy link

xblad 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
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
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
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
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
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 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
Copy link

90debasish 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

@byronz
Copy link
Contributor

byronz commented Jul 29, 2019

issue has been fixed in

dash                 1.0.2
dash-core-components 1.0.0
dash-html-components 1.0.0
dash-renderer        1.0.0
dash-table           4.0.2

@byronz byronz closed this as completed Jul 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dash-meta-good_first_issue dash-type-bug Something isn't working as intended
Projects
None yet
Development

No branches or pull requests

4 participants