onRefresh of updateSharedInformation is ignored when the editor is in an invalid state
It seems that the value in an updateSharedInformation
is not updated by an onRefresh
when the editor is in an 'invalid' state. In the below example, first fill in a value, then remove it (the icon becomes red), and then click the Continue button. I would expect the editor to get the new value, but it doesn't.
This seems to be because of this part of updateSharedInformation
:
(mapEditorWithState ?None
(\(r,valid) _ -> (if valid (?Just (tof r)) ?None, ?Just r))
(\mbv (?Just r) -> ((fmap (fromf r) mbv, isJust mbv), ?Just r))
editor
)
The if valid
only accepts changes when the value is valid. This is to make sure that the user can actually enter an invalid value (otherwise the last valid value is restored), but also blocks 'external' refreshes.
Or do I misunderstand the concept again, @baslijns?
import iTasks
:: R = {x :: String}
derive class iTask R
Start w = doTasks (withShared {x=""} task) w
task share =
updateSharedInformation [] share -&&-
(viewInformation [] "Set the value?" >!| set {x="new value"} share)