Bug introduced in V10.4 or earlier and persisting through V11.3
CASE:3875733, confirmed
It seems that Dynamic
content is somehow cached by PaneSelector/FrontEnd
.
Even weirder, it does respond to evaluation though it uses old values, incorrectly.
Here is a minimal example:
(*our panel, Dynamic + := may seem strange but remember this is only an example*)
paneContent[] := Dynamic[Print[1]; DateString[]]
(*our app implementation with PaneSelector*)
DynamicModule[{pane},
Panel @ Column[{
Button["test", pane = "pane"],
Button["init", pane = "init"],
PaneSelector[{
"default" -> "default",
"pane" -> Dynamic[pane; Print["pane"]; paneContent[]]
}
, Dynamic[ pane ], ImageSize -> {200, 50}
]
}]
]
(*same functionality implemented with Dynamic only*)
DynamicModule[{pane = "init"},
Panel@Column[{
Button["test", pane = paneContent[]],
Button["init", pane = "init"],
Pane[Dynamic[Print["pane"]; pane], {200, 50}]
}]
]
Now toggle between test and init and observe what happens.
The second panel updates date while the first show only the initial one. Even though the Print[]
statement is evaluated! I don't understand this at all, it seems that FrontEnd caches paneContent[]
somehow.
Can I prevent that?
paneContent[]:=Dynamic[pane;Print[Stack[_]];DateString[]]
with"pane" -> paneContent[]
seems working. So it looks like theDynamic
inpaneContent[]
needs to be triggered explicitly. But I don't understand what is the relation between the globalpane
and the localizedpane
. $\endgroup$paneContent
is independent fromDynamicModule
so can't use it. The more that bareDynamic
works, I just won't usePaneSelector
. For me it is just crazy that this printsPrint["pane"]; paneContent[]
but it doesn't evaluatepaneContent[]
. I suppose it is a side effect of something which should have made our lifes easier, again. Thanks for your attention :)\ $\endgroup$