Updating view model from toolbar button - warning about undefined behavior

Hi I have a toolbar that has an edit and then save/cancel buttons after the edit button is pressed.

When I press the save button I'm updating the view model (which is an @state variable) in the button's closure, but am getting the dreaded "Modifying state during view update, this will cause undefined behaviour." warning.

If I do the same, but with buttons in the form instead of the toolbar, I don't get the warning. Is there something unique about toolbar buttons and is there a way to have them update the view model without getting this warning?