-
-
Notifications
You must be signed in to change notification settings - Fork 144
PersistenceTransforms for date in datePickerRange and datePickerSingle #854
Conversation
DatePickerRange.persistenceTransforms = { | ||
end_date: { | ||
extract: propValue => { | ||
if (!(propValue === null || propValue === undefined)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is fine but can be simplified by using https://ramdajs.com/docs/#isNil instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
return propValue; | ||
}, | ||
apply: storedValue => storedValue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation for end_date
and start_date
extract and apply are identical (same for DatePickerSingle date
) -- DRY by defining a functions that you can share between the 3 cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
dash_dcc.start_server(app) | ||
dpr1 = dash_dcc.find_element("div#dpr1 div div div div .DateInput_input") | ||
dpr2 = dash_dcc.find_element("div#dpr2 div div div div .DateInput_input") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it work with only div#dpr2 .DateInput_input
? This find_element
seems to be very dependent on the implementation details of the underlying third-party component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See 605594c . Now we use only the dash_dcc
functions for interacting with date pickers, and are testing the behaviour DatePickerSingle and Range defined in callbacks, with the date
, start/end_date
props changing value each time the callback is fired.
.circleci/config.yml
Outdated
@@ -80,7 +80,7 @@ jobs: | |||
command: | | |||
. venv/bin/activate && mkdir packages | |||
# build main dash | |||
git clone --depth 1 https://github.com/plotly/dash.git dash-main | |||
git clone -b persistence-hg --depth 1 https://github.com/plotly/dash.git dash-main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With plotly/dash#1376 now merged, this can be 🔪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -263,6 +266,11 @@ DatePickerRange.propTypes = { | |||
persistence_type: PropTypes.oneOf(['local', 'session', 'memory']), | |||
}; | |||
|
|||
DatePickerRange.persistenceTransforms = { | |||
end_date, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assign the value to the prop instead of assigning to a value that matches the prop for shortcut assignation
end_date, | |
end_date: transformDate, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- now needs to be run against dash
dev
- needs a changelog entry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃
In conjunction with plotly/dash#1376, fixes #700.
The persistence logic in
DatePickerRange
andDatePickerSingle
have been modified to extract/apply just thedate
portion of thedate-time
. This will provide stability to date pickers (eg defined in callbacks) for the entire day they are defined.