Skip to content

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

@useless5771

Description

@useless5771

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions