-
-
Notifications
You must be signed in to change notification settings - Fork 144
some issue with tabs reverting their value? #331
Comments
I'm looking into this but I'm not sure if it's really a Tabs problem, that is, I think it might be an issue in dash-renderer where the updating of props is not happening 100% correctly. Here's a console output of this example taken from the forums:
after clicking on the 2nd tab, the Tab's internal |
Yeah, that sounds plausible. This is the first component that has demonstrated an implicit link between children and parents, and so I wouldn't be surprised if there was some surprising behaviour, probably when we're doing a I'd try to keep the
have:
That is, if it's connected to dash-renderer ( |
@chriddyp Ah yeah, so that's the same problem as this issue right? I tried to come up with a better solution for that but haven't yet. That suggestion is interesting and probably a good idea, but in the example above there are no callbacks assigned to the Tabs, so won't that leave |
Yeah, good point. Could you be a little more precise on this statement?
Do you mean the |
Sorry, that was confusing, let me rewrite that. Then, if I click on a radio button, |
It's also being updated in dash-core-components/src/components/Tabs.react.js Lines 153 to 160 in d004b29
|
Oh, yes, you're right. |
So I guess it's receiving new props coming from dash-renderer there. Only, it shouldn't - there are no callbacks being fired that involve Tabs. |
Yeah, so you can't assume that In this case it seems excessive, but imagine if a callback updated a different property of the Tabs like |
Ah right, I remember now. I think my thinking was this: when the Tab's value get's updated, for example in What's the solution then? If we want users to use the Tabs without a callback, then I don't see a way of updating the value prop in Dash if We could add a Any other suggestions? |
What about something like this:
|
Hmm I don't think that would solve anything, unfortunately! The issue is that the Basically, the way of using Tabs without a callback is kind of flawed, because Dash needs to be informed about prop changes, but can't update Dash on prop changes without |
Here's the logic where we determine whether or not to pass in From that logic, I forget if that we're checking if that component is an output or if we're checking if it's an input but I believe that its checking if that component has any properties that are If so, you're right in that the component could be an output, so we still need to check if any props have changed, we can't just rely on And since the However, no other property can change within the tab itself (via user interaction), so we don't need to hold anything else in state, we only need to keep track of So, could we have logic like this?
In summary:
|
@chriddyp You're absolutely right - I was thinking of it in the wrong way and didn't realize that we could just skip using this.state if setProps was defined. Was a pretty easy fix in the end, I was just going down the wrong rabbit hole I guess! Thanks for your help. I've pushed a fix to #315, maybe you can review it? |
It's being reported in the community forum: https://community.plot.ly/t/problem-with-callbacks-in-different-tabs/13044/13?u=chriddyp
The text was updated successfully, but these errors were encountered: