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

Commit

Permalink
Merge pull request #930 from ravij3/fix-off-by-one-datepicker
Browse files Browse the repository at this point in the history
Fixing off by one error in DatePickerRange.
  • Loading branch information
alexcjohnson authored Mar 4, 2021
2 parents 495097b + 687c336 commit a7a85ad
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- [#923](https://github.com/plotly/dash-core-components/pull/923)
Set autoComplete to off in `dcc.Dropdown`. This fixes [#808](https://github.com/plotly/dash-core-components/issues/808)

### Fixed
- [#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.

## [1.15.0] - 2021-01-19
### Fixed
- [#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).
Expand Down
5 changes: 4 additions & 1 deletion src/fragments/DatePickerRange.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export default class DatePickerRange extends Component {
}

isOutsideRange(date) {
const {min_date_allowed, max_date_allowed} = this.props;
const {min_date_allowed, max_date_allowed} = convertToMoment(
this.props,
['min_date_allowed', 'max_date_allowed']
);

return (
(min_date_allowed && date.isBefore(min_date_allowed)) ||
Expand Down
29 changes: 29 additions & 0 deletions tests/integration/calendar/test_date_picker_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,32 @@ def test_dtpr003_no_initial_month_no_min_date_start_date(dash_dcc):
"#dps-initial-month .CalendarMonth.CalendarMonth_1[data-visible=true] strong",
"August 2019",
)


def test_dtpr004_max_and_min_dates_are_clickable(dash_dcc):
app = dash.Dash(__name__)
app.layout = html.Div(
[
dcc.DatePickerRange(
id="dps-initial-month",
start_date=datetime(2021, 1, 11),
end_date=datetime(2021, 1, 19),
max_date_allowed=datetime(2021, 1, 20),
min_date_allowed=datetime(2021, 1, 10),
)
]
)

dash_dcc.start_server(app)

dash_dcc.select_date_range("dps-initial-month", (10, 20))

dash_dcc.wait_for_text_to_equal(
'#dps-initial-month .DateInput_input.DateInput_input_1[placeholder="Start Date"]',
"01/10/2021",
)

dash_dcc.wait_for_text_to_equal(
'#dps-initial-month .DateInput_input.DateInput_input_1[placeholder="End Date"]',
"01/20/2021",
)

0 comments on commit a7a85ad

Please sign in to comment.