-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Prevent loss of domain information when template field is present in layout #7283
base: master
Are you sure you want to change the base?
Conversation
newFullLayout[key].domain = oldFullLayout[key].domain; | ||
} else if (newDomain[0] !== oldDomain[0] || newDomain[1] !== oldDomain[1]) { | ||
// what you're asking for HAS changed, so clear _inputDomain and let us start from scratch | ||
newFullLayout[key]._inputDomain = null; |
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.
I think nestedProperty(...).set(null)
is actually equivalent to delete newFullLayout[key]._inputDomain
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.
@alexcjohnson Using delete
may be slower comparing to setting to null
. No?
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.
I suppose that’s faster and should be equivalent. This is not a high volume operation so I wouldn’t be too concerned about it, but we can leave it if you prefer.
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.
I was using this syntax for consistency with the other places in the codebase that delete this field, but I don't have a strong opinion on which we use.
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.
@marthacryan Maybe worth leaving a comment explaining why we do nothing in the else
case? (I know we discussed but... for posterity)
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.
Ah yeah good point Emily!
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.
@alexcjohnson I added a comment explaining the else case based off of this explanation from you about that case:
"this situation is perhaps actually ambiguous: did you pass back in the previous layout as modified by Plotly.js, so we should assume you really wanted _inputDomain to still apply? or did you explicitly set the new domain and it just happened to match the old final calculated domain - in which case we should clear _inputDomain. I guess generally oldDomain will be some random floating point number so it's unlikely you matched it exactly. better to assume you passed back in the same layout object and change nothing in this case."
Let me know if you have any corrections!
@marthacryan Thanks very much for another excellent PR. 🏆 |
@marthacryan Could you please add a test to lock the bug you fixed in this PR? |
@archmoj Done! I added it to the |
Alternative fix to plotly/plotly.py#4794. Other fix is #7282.
Context:
editType
from'calc'
to'plot'
is more of a downgrade than something that should fix this issue._inputDomain
, but that this line was returning indiffFlags
before it reached the yaxis to reset it_inputDomain
in thechanged
function was actually incorrect. It should be reset in its own separate crawl of the layout._inputDomain
into thediffLayout
function because it has access to both the old layout and the new layout.