Skip to content
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

Refresh value of variable bound to widgets with options generated by R function #241

Open
useless5771 opened this issue Jun 15, 2017 · 1 comment

Comments

@useless5771
Copy link
Contributor

useless5771 commented Jun 15, 2017

This got exposed when testing #224 - when function producing options for select/checkbox/radiobuttons group returns different values depending on state of some other widget, the value of the variable representing the select widget may become stale.

E.g.
Assuming that there are two widgets:

  • optionsType radiobutton - with two available options: 'colors' and 'vegetables'
  • typedOptional checkbox group - which is populated by a function that depending on optionsType selection returns:

** red, green, blue if optionsType has value 'colors'
** plums, tomatoes, potatoes if optionsType has value 'vegetables'

Lets assume that user has selected 'colors' optionType and they have 'red' and 'blue' options ticked off.
When they change the option type to 'vegetables' the UI will get updated, and none of the available vegetables will be checked out, but the variable typedOptional will still have the 'blue' and 'green' value.

This means that all other widgets that depend on typedOptional will use stale value of that variable.

The suggested solution for this is to make sure that for (multi)select/checkbox and radiobutton group which get available options from R function the value gets refreshed/reset when control is identified as affected by change in the UI (through dependency graph).

The business rules for the refresh could be:

  • if current value is null do nothing
  • new value <- intersection of current value and available values

Note!

Currently the multi-select widget does not expose this issue only because it (incorrectly) triggers window.RCAP.controlUpdate when its state is synced from R - resulting in loopback (this also exposes as double-refresh of dashboard).

@shaneporter
Copy link
Collaborator

Thank you @useless5771!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants