-
-
Notifications
You must be signed in to change notification settings - Fork 145
support datepickersingle as an uncontrolled component #532
Conversation
Are we committed to keeping these jest tests? I feel like they hook too far deeply into the underlying implementation ( The actual behaviour is already tested in the integration tests. |
Does I'm OK with this as a stopgap, but please open an issue in |
It does, a similar commit is on its way up.
|
Dunno about these specific ones, if you're confident the behavior they're testing is covered elsewhere feel free to 🔪. But I do like having the framework around for situations where we want to test a million similar cases more efficiently than selenium keypresses. |
as we’re not holding the date in state anymore
|
oh no! i'll leave that one to you @byronz 😸 |
@chriddyp I think the test failure captures a bug in implementation logic |
if (start_date && !start_date.isSame(oldMomentDates.start_date)) { | ||
if (updatemode === 'singledate') { |
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 swallow the start date in bothdates
mode
@@ -44,7 +44,8 @@ | |||
# export PERCY_PROJECT=plotly/dash-integration-tests | |||
# export PERCY_TOKEN=... | |||
|
|||
TIMEOUT = 20 | |||
|
|||
TIMEOUT = 10 |
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
dash-renderer
, we now providesetProps
for all components, regardless of whether they are connected to the backend.However, the
setProps
that we provide needs an ID in order for it to update the component:https://github.com/plotly/dash-renderer/blob/84c484b26452458a28843d02e4431cc88a623e14/src/TreeContainer.js#L146-L181
Some of our components, like
DatePickerSingle
, have legacy logic that handled oldsetProps
logic - they wouldsetState
ifsetProps
wasn't defined.In some cases, like
DatePickerSingle
, this logic wasn't tight: instead of just callingsetState
, they would callsetProps
andsetState
, which makes it pretty hard to reason about when renderings happen. It's also fragile - ifdash-renderer
changes the way that it renders components, that rendering order may break the components.I believe this is what happened in the
dev-tools
PR - the way that the components were rendered bydash-renderer
changed which caused some of this fragile logic to break the components in certain cases.This PR improves the state/props management of
DatePickerSingle
to be explicit about when to use state and when to use props by making it conditional on the presence of theid
.It also cleans up the moment-conversions by treating them as a data conversion step during render. It was pretty hard to reason about the logic before (moment props were in state)
In practice, most controls will have an ID (as they are inputs to callbacks). However, as users are authoring their app's layout, they may include some controls without IDs to start. If we don't manage the state, then the user may be surprised the component reacts different to user input when it is "unconnected" (without an ID) vs when it is connected.
This should fix the image tests issues we are seeing in #523