FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
125 stars 25 forks source link

Terminate in Action Block doesn't stop action #2836

Closed d6p2b closed 6 months ago

d6p2b commented 6 months ago

Has your issue been reported?

Current Behavior

A "terminate" action in part of an action block doesn't stop an action flow which includes the action block.

Expected Behavior

The "terminate" should stop the entire action flow.

Steps to Reproduce

  1. Create a new project.
  2. Add a button to trigger the action flow with an on-tap action.
  3. Create an action block which contains a confirmation dialog and "terminate" connected to the cancel side.
  4. Create an action flow with two actions: the block from step 3 and a snack back to show whether or not the terminate did anything.
  5. Run the project.
  6. Click the button to trigger the action and click either cancel or confirm. In both cases the final snackbar will appear.

Reproducible from Blank

Bug Report Code (Required)

IT4Cl/KB249OxLlE7ZDAb/owvyQsH1whRY0NmtVHawIaJ5PMC+wIZ/f7XFRuTde0SlFMfWKjjj41w+/emvz1A/cEAxyec4Q71ZFQcjvMLU+jWr61CKm0R25/DdxbN2XF5ruzoRUmKsRtWkI4206qG+u+d3fvNITJDVc8ReW1C5CK2SrDX1iXc2URm05KZDPz

Context

My project has forms where the nice user might be tempted to navigate away from a page with unsaved changes using several different flows. I want to have a single action block to insert in all the navigation actions to warn the user about the unsaved changes and offer a chance to stop the navigation. Since the "terminate" doesn't stop the "parent" action, the user has no chance to stop the navigation.

Visual documentation

image

image

Additional Info

No response

Environment

- FlutterFlow version: 4.1.45
- Platform: all
- Browser name and version:  any
- Operating system and version affected: any

General

Relative to the time the changes were made, data was lost within

When following my steps to reproduce, data loss happens

rzambroni commented 6 months ago

Hi @d6p2b, i was able to replicate the problem you are describing, will send it to the team so they can take a look.

Thanks for the report!

takashiff commented 6 months ago

Hi @d6p2b, thanks for the bug report! Due to the way action blocks are coded, this is intentional behavior. Action blocks are stored completely separately from the action chain itself, so if you take a look at the code the button you have provided, you'll see the action block getting called before the snack bar shows up. Since the "terminate" is just a return statement, the action block terminates from the return (thus causing the action block to be terminated), and then the next action is called afterwards (in this case, the snack bar). Hope this clears things up for you. Thanks!