Skip to content

Commit c468288

Browse files
committed
Merge pull request #930 from ravij3/fix-off-by-one-datepicker
Fixing off by one error in DatePickerRange.
1 parent f3297c6 commit c468288

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

Diff for: packages/dash-core-components/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1515
- [#923](https://github.com/plotly/dash-core-components/pull/923)
1616
Set autoComplete to off in `dcc.Dropdown`. This fixes [#808](https://github.com/plotly/dash-core-components/issues/808)
1717

18+
### Fixed
19+
- [#930](https://github.com/plotly/dash-core-components/pull/930) Fixed a bug [#867](https://github.com/plotly/dash-core-components/issues/867) with `DatePickerRange` that would sometimes shift the allowed dates by one day.
20+
1821
## [1.15.0] - 2021-01-19
1922
### Fixed
2023
- [#905](https://github.com/plotly/dash-core-components/pull/905) Make sure the `figure` prop of `dcc.Graph` receives updates from user interactions in the graph, by using the same `layout` object as provided in the prop rather than cloning it. Fixes [#879](https://github.com/plotly/dash-core-components/issues/879).

Diff for: packages/dash-core-components/src/fragments/DatePickerRange.react.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ export default class DatePickerRange extends Component {
8282
}
8383

8484
isOutsideRange(date) {
85-
const {min_date_allowed, max_date_allowed} = this.props;
85+
const {min_date_allowed, max_date_allowed} = convertToMoment(
86+
this.props,
87+
['min_date_allowed', 'max_date_allowed']
88+
);
8689

8790
return (
8891
(min_date_allowed && date.isBefore(min_date_allowed)) ||

Diff for: packages/dash-core-components/tests/integration/calendar/test_date_picker_range.py

+29
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,32 @@ def test_dtpr003_no_initial_month_no_min_date_start_date(dash_dcc):
8080
"#dps-initial-month .CalendarMonth.CalendarMonth_1[data-visible=true] strong",
8181
"August 2019",
8282
)
83+
84+
85+
def test_dtpr004_max_and_min_dates_are_clickable(dash_dcc):
86+
app = dash.Dash(__name__)
87+
app.layout = html.Div(
88+
[
89+
dcc.DatePickerRange(
90+
id="dps-initial-month",
91+
start_date=datetime(2021, 1, 11),
92+
end_date=datetime(2021, 1, 19),
93+
max_date_allowed=datetime(2021, 1, 20),
94+
min_date_allowed=datetime(2021, 1, 10),
95+
)
96+
]
97+
)
98+
99+
dash_dcc.start_server(app)
100+
101+
dash_dcc.select_date_range("dps-initial-month", (10, 20))
102+
103+
dash_dcc.wait_for_text_to_equal(
104+
'#dps-initial-month .DateInput_input.DateInput_input_1[placeholder="Start Date"]',
105+
"01/10/2021",
106+
)
107+
108+
dash_dcc.wait_for_text_to_equal(
109+
'#dps-initial-month .DateInput_input.DateInput_input_1[placeholder="End Date"]',
110+
"01/20/2021",
111+
)

0 commit comments

Comments
 (0)