-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Component properties set through dynamic callbacks cannot be persisted #2678
Comments
I did notice this also today, and it is pretty annoying. As you said, once the I have the feeling this is intentional because on the doc page it says
so it seems a user interaction is always necessary for persistence to work. But it would be good to have an official clarification from the Dash development team. |
I think this is a duplicate of #1252 - and yes as I said there:
ie if we need a single rule for this, I think the current behavior is correct, but there's clearly an appetite for more flexibility so if we can understand it we can certainly think about an extension of the feature. |
Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are most important to our community. If this issue is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. (Please note that we will give priority to reports that include a short reproducible example.) If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson |
@gvwilson please would it be possible to reopen this issue? @alexcjohnson I've seen this issued discussed in several places (here, #1252, plotly forums 1 2 3) and there appear to be several uses for it. Let me just add another one here. It's not possible to persist some user inputs, and so your idea of setting the persisted value through a callback output unfortunately doesn't work e.g. say you have a callback with Outside of concrete users for this, judging by the repeated questions about this over the years, I think that the current behaviour causes quite a bit of confusion and awkward workarounds since it doesn't seem to follow typical Dash user expectations. If the proposed behaviour might be undesirable in some scenarios then perhaps there could be a new option that switched between the two behaviours? This may seem like a minor thing but for our specific case it turns out to actually be quite important 😅 So if there were any way to prioritise this issue then it would be super helpful and we would be very grateful 🙏 My colleague @petar-qb and I would even be happy to try and contribute a fix if you could offer some guidance. |
@gvwilson thanks very much for reopening this! Just to understand, what does priority P3 mean in practice? Is there anything we could do to accelerate this being fixed? @petar-qb and I are very happy to help raise a PR or similar, but we would need some discussion with the Dash team first about what would be correct solution and how to implement it. |
Hi @antonymilne - P1 means "someone should be working on it right now", P2 is "we're looking at including it in the next sprint", and P3 is "everything else" :-) If you and @petar-qb are willing to work up a PR, I can ask @T4rk1n to chat with you about what would be required where - we're hoping to get a Dash release out next week, so we could start the conversation after that. |
Hello @gvwilson. Now that the Dash release is done we'd love to try and make some progress on this. Please do let me know the best way forward 🙏 |
hi @antonymilne - can you please email me (greg.wilson@plot.ly) and suggest a few times Monday or Tuesday next week that would work for a quick chat and I'll set one up? thanks - @gvwilson |
For references on how we record the persistence, the function to call is: dash/dash/dash-renderer/src/persistence.js Line 309 in 9566578
An example of the call can be found here: dash/dash/dash-renderer/src/TreeContainer.js Line 168 in 9566578
The I think the easiest way to ensure the record without adding a call every where would be to refactor the
Into a function like: // Change the variable name of the action
export const onPropChange = createAction(getAction('ON_PROP_CHANGE'));
export function updateProps(payload) {
return (dispatch, getState) => {
const component = path(payload.itempath, getState().layout);
recordUiEdit(component, payload.props, dispatch);
dispatch(onPropChange(payload));
}
} With that can remove the call at dash/dash/dash-renderer/src/TreeContainer.js Line 168 in 9566578
If we want to put a flag to enable the persistence on a callback basis, could add an argument to Lines 63 to 74 in 9566578
Pass it along on the Lines 249 to 263 in 9566578
Then add the same key to the typescript definition: dash/dash/dash-renderer/src/types/callbacks.ts Lines 3 to 17 in 9566578
We can return to the updateProps function and do a check const {enable_persistence, ...restPayload} = payload;
if (payload.source !== "response" || enable_persistence) {
const component = path(payload.itempath, getState().layout);
recordUiEdit(component, payload.props, dispatch);
} Then just add the function applyProps(id: any, updatedProps: any, enable_persistence: boolean) {
...
dispatch(
updateProps({
itempath,
props,
source: 'response',
enable_persistence,
})
); Then the call
To const appliedProps = applyProps(parsedId, props, cb.callback.enable_persistence); |
Wow @T4rk1n, this is super helpful and will surely accelerate the developing! 🏅 |
I found that for a component with persistence=True set, if its properties are set through callbacks, the properties cannot be persisted when the web page is reloaded.
I don’t know if this is a bug or an intentional design?
I think if there is no difference between manual modification and callback settings, the experience will be better both intuitively and in terms of freedom.
The text was updated successfully, but these errors were encountered: