Here's a nice one-
Selecting a data-point in the visual's initial update() call makes most/all sandboxed visuals get the WRONG DataView.
Background:
I developed a simple visual called RadioSlicer, which is a single-selection slicer that must have one data-point selected at any given moment. Therefore, it needs to have a data-point selected as soon as it gets its data. In order to do so, I had the visual select the first data-point(by using either SelectionManager.select() or HostServices.onselect()) on update() if no other selection is present.
Scenario:
Prior to sandboxing, it worked perfectly fine. But now the following scenario occures:
On a multiple-page report, I have a page that contains a RadioSlicer and some other custom visuals. Everything function properly when I enter the page for the first time. But when I leave the page and then go back to it, most/all the other custom visuals have their DataViews mixed. For example, on a page that displays a list of employees and have a RadioSlicer for department selection, following the above scenario might lead to the RadioSlicer displaying employee names instead of department names(and the employees list displaying department names) and have the first employee selected.
Additional Information:
- When I comment out the line where the selection is made, this issue does not occur.
Edit:
I wrote a less-than-optimal workaround for this issue that delays the selection to ~250ms after the last post init() call to update() by putting the selection expression in a timeout callback and resetting the timeout on subsequent calls to update().
This workaround is less-than-optimal mainly because it works only in fast-enough environments. When tested in a sluggish environment(A virtual machine with low resources, to be specific), the issue was still encountered.