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

When prior=true, keep looking for old_user_dict #707

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

BryceStevenWilley
Copy link
Contributor

If you don't keep looking for old_user_dict, you might first reach objects that still exist in the rewound user_dict, which might exist, but won't have attributes set before the back button press.

Specifically fixed a bug found when modifying https://docassemble.org/docs/background.html#background_response to be used on an object (at the bottom).

Happy to modify or do any more testing; it seems like it could be a big change, but does seem like the right behavior for prior=True.

objects:
  - address: Address
---
question: |
  Where do you live?
fields:
  - Country: address.country
    code: countries_list()
  - State: state
    code: |
      states_list(country_code=showifdef('address.country', 'US', prior=True)) or ['N/A']
    js enable if: val('address.country')
check in: update_states_list
---
event: update_states_list
code: |
  if action_argument('_changed') == 'address.country':
    background_response({
      'state': {
        'choices': states_list(country_code=action_argument('address.country')) or ['N/A']
      }
    }, 'fields')
  background_response()
---
mandatory: True
question: |
  You live in
  ${ state_name(state, country_code=address.country) }
  in
  ${ country_name(address.country) }.
subquestion: |
  Your country code is `${ address.country }`.

  Your state code is `${ state }`.

Also confirmed that showifdef works on the original recipe as expected, and in a few other cases.

If you don't keep looking for `old_user_dict`, you might first reach objects
that still exist in the rewound `user_dict`, which might exist, but won't have
attributes set before the back button press.
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

Successfully merging this pull request may close these issues.

2 participants