Open nickgeoca opened 8 years ago
Nick, for this purposes is the "pageFlow" modifier.
This bad effect is unavoidable in monadic flows when there are alternative branches and the page is not fully rendered, since the generator of field identifiers assign them sequentially and the values are filled from the previous interactions. `pageFlow´ add a prefix that prevent the new fields to be populated with values from other branches.
when the second getInt
is rendered for the first time, it receives the
identifier "p1" but this "p1" was in the previously the identifier of
the submitButton
field, that had "submit" as value, so the generator
wrongly assign this to the second sum field. But this is unavoidable unless
submitButton is preceded with a
pageFlow` prefix, so that the identifier
generated for this field do not clash with the ones of the sum:
main = runNavigation "" . step . page . pageFlow "s" $
do n1 <- "First " ++> getInt Nothing <++ br
n2 <- "Second " ++> getInt (Just n1) <++ br
p << (n1 + n2) ++> noWidget
<** br ++> pageFlow "button" (submitButton "submit")
In this example, the submintButton
field receive the identifier
"submitp0" the first time that it is rendered, so there is no clash with
the monadic expression above. the zero is because pageFlow
also restart
the field counter for the branch.
Description: After the 1st number is entered in the First field, the Second field is populated with "submit". As seen in picture below. The code sample is below too. Note that changing "(Just n1)" to "Nothing" does not change the behavior.![image](https://cloud.githubusercontent.com/assets/2054736/10562717/6095e2aa-752f-11e5-9436-6e15309dc2f4.png)
Line: n2 <- "Second " ++> getInt (Just n1) <++ br
Version
Code