Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Store props from callback #1900

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

Open
wants to merge 4 commits into
base: dev
Choose a base branch
Loading
from

Conversation

nickmelnikov82
Copy link
Member

@nickmelnikov82 nickmelnikov82 commented Jan 25, 2022

As described in issue #1596 and #1856 props passed by callback are not saved in storage. This PR makes it possible to save props.

Contributor Checklist

  • I have broken down my PR scope into the following TODO tasks
    • Implement saving persisted props passed by callback
    • Add integration test
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

optionals

  • I have added entry in the CHANGELOG.md
  • If this PR needs a follow-up in dash docs, community thread, I have mentioned the relevant URLS as follows
    • this GitHub #PR number updates the dash docs
    • here is the show and tell thread in Plotly Dash community

@nickmelnikov82 nickmelnikov82 force-pushed the store-props-from-callback branch from cdf9b8e to bf208c4 Compare January 25, 2022 14:43
@@ -306,6 +306,55 @@ const getProps = layout => {
};
};

export function setPersistance(layout, newProps, dispatch) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickmelnikov82 my apologies for not reviewing this quicker!

Can you explain the differences between this new function and recordUiEdit? Ideally we'd 🌴 combine them into one (which we could call recordEdit I guess) with just a flag to distinguish the two situations, then any differences would be crystal clear.

The differences I see:

  • Here you needed to create finalPersistence - makes sense because the UI can't edit persistence - but in fact I don't see a harm in including this in recordUiEdit, it's not a big overhead. Which brings up that in the callback case it's also possible to alter persistence_type, so presumably we should also create finalPersistenceType.
  • Why the short-circuit on finalPersistence !== persistence? I guess maybe it's more complicated in this case, at least if you change from one truthy persistence value to another, but it seems to me like we'd still want the new value stored.
  • Can you explain the storage.removeItem case? Is that situation accessible from the UI as well (ie a case we were always missing)?
  • recordUiEdit has const vals = originalVal === undefined ? [newVal] : [newVal, originalVal]; - ie we don't store undefined. I'm not sure the practical consequences of this, but presumably we want to keep that behavior?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. About finalPersistenceType it makes sense
  2. Yes, it's related to case when one truthy persistence value to another. When persistence is changed, the current value is immediately written to the storage as the original value.
  3. This is for the case described in the documentation
  4. Without these lines, more than half of the tests fail. I'm not quite sure how storage without the original value is used.

@nickmelnikov82 nickmelnikov82 force-pushed the store-props-from-callback branch from 417b4fa to 747f63e Compare April 15, 2022 07:56
@nickmelnikov82 nickmelnikov82 force-pushed the store-props-from-callback branch from 747f63e to 45c20af Compare April 22, 2022 14:30
@AnnMarieW
Copy link
Collaborator

A related issue is the persistence doesn't work when a prop is set using query strings or path variables in a multi-page app.

Here's a great example (thanks @nopria ) : https://github.com/nopria/dash-persistence-test

Will this PR address this case as well?

@gvwilson gvwilson self-assigned this Jul 24, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added P2 considered for next cycle fix fixes something broken labels Aug 13, 2024
@gvwilson
Copy link
Contributor

@T4rk1n can you please let us know if this one is still current or has been superseded or gone stale? thanks - @gvwilson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix fixes something broken P2 considered for next cycle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.