Problem updating (nested) structurefield

Hello,
I’m trying to update a nested structure field.
First of all i save the panel page, to be sure that everything is saved there (no orange bottom bar).
Then i run my code! This works, when i check the content-txtfile, the values are updated.
But when i go to the panel again, the orange update/revert bar pops up again. When i hit save, the changes dissapear.
Could this a bug or am i doing something wrong?

Below my code:

blueprint

fields:
  blocks:
    type: structure
    label: Blocks
    fields:
      name:
        label: Block Name
        type: text
      days:
        label: Days
        type: structure
        fields:         
          date:
            label: Date
            type: date
          registered:
            label: Registered  //this one needs to be updated
            type: number
            default: 0

with this code:

$accommodationpage->update([
 'blocks' => $updateblocks
]);

What’s in $updateblocks.

this is the stripped code:

$updateblocks=[];
$blocks=$accommodationpage->blocks()->yaml();
foreach($blocks as $block){	 				
	for($i=0;$i< count($block["days"]);$i++){ 
		$block["days"][$i]["registered"]=$block["days"][$i]["registered"]+1;
	}
	$updateblocks[]=$block;
}

$accommodationpage->update([
	'blocks' => $updateblocks
]);

Do the changes to your content file show up in the Panel and the problem is only the save bar, or are the frontend changes not reflected at all when you revisit the Panel?

The frontend changes are not reflected when you revisit the Panel.

I have been doing a lot of tests today and i think i know how you can simulate the problem.

When you open a structurefield, you can browse through the structures via the arrows like in the pic below. Now you click “ok” to close the structurefield. You can now go to another page.

Now i run my code.

Then i go back to the panelpage with the structurefield and then the orange bar popups and there are no changes reflected. When i hit revert, than i see the changes i made via my code.

The problem occurs with every structurefield, not only nested structurefields.

I guess you’re not doing this in a hook but from a form in the frontend? So that is basically resembles manually updating the content in the file system?

yes, that’s correct.

I did some more tests. You have the problem when you open and closes a structurefield. But if you do a pagerefresh afterwards on that page or you save something else on that page, before doing the code, there is no more error.

Could you please create an issue on GitHub?