-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Store callback Output value in persistence storage #3279
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
base: dev
Are you sure you want to change the base?
Store callback Output value in persistence storage #3279
Conversation
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.
Looks good, but there is a failing test rdps011. I am not sure if it's because the behavior changed to persist value on callbacks or if it's a regression.
Maybe @alexcjohnson can provide more insights on this test?
const transforms = element.persistenceTransforms || {}; | ||
for (const propName in newProps) { | ||
const propTransforms = transforms[propName]; | ||
if (propTransforms) { | ||
for (const propPart in propTransforms) { | ||
finalStorage.removeItem( | ||
getValsKey( | ||
id, | ||
`${propName}.${propPart}`, | ||
finalPersistence | ||
) | ||
); | ||
} | ||
} else { | ||
finalStorage.removeItem( | ||
getValsKey(id, propName, finalPersistence) | ||
); | ||
} |
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.
What did this do? It's inclusion/removal doesn't seem to have an effect.
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 issue with this code is that it clears the persisted value before the new selection is written via recordUiEdit
, once the callback is triggered. For example, if the storage initially contains [[1, 2], []]
and callback_select_all
(which selects [1, 2, 3]
) is triggered:
- The removed code clears the persistence storage prematurely which causes the original value (
originalVal
) to be lost, which is problematic. - Then
recordUiEdit
writes[[1, 2, 3], [1, 2]]
into storage.
This is incorrect because what should be persisted is [[1, 2, 3], []]
.
I might need to handle this differently. What do you think?
…value-in-persistence-storage
Fixes #2678
This PR:
TLDR:
This PR ensures that the callback output value is written (instead of being pruned) within the browser's persistence storage for its
dcc
components that haspersistence=True
set.For the following code (also posted in the Dash Plotly forum question that's linked above):
Here's how it works from the
plotly/dash::dev
:Screen.Recording.2025-01-30.at.11.07.24.mov
Here's how it works from the
petar-qb/dash::feature/store-output-value-in-persistence-storage
:Screen.Recording.2025-01-30.at.11.09.25.mov
Contributor Checklist
optionals
CHANGELOG.md