Odd behaviour when editing locally vs in browser IDE, plus rolling back versions

Hi, I have noticed some odd behaviour when editing code locally and then pushing the changes via Git.
I can’t exactly say what is causing it, but it is as though some code referencing Anvil components don’t get “linked” to their counterparts in the IDE when it is pushed and run in the browser. For example, when I edit on_click behaviour for a form button locally and then push that change, it seems like the code doesn’t react, even if the component name is correct etc… I will have to do some more testing to describe it more accurately, but curious if anyone has seen this behaviour before?
When making the changes online in the Anvil IDE I don’t seem to have this issue.

Also, sometimes I load an older version of the app in Version History, but then I want to make a change to it and fork from that point in time, but the IDE won’t let me… it just says “changes can’t be made… now the app will reload”. For example, if I noticed in a later revision that I’ve made some change that broke the app, and I want to go back.
Is there an easy way to roll-back to a previous point in time, or fork from a previous commit and continue using that older fork?

Right click on the commit you want to go back to, and reset your master branch to that commit.

1 Like

Two things may be happening here:

  • you pushed a commit from your computer, the app already loaded in the browser knows about it, but has not checked it out yet
  • the ide doesn’t allow you to edit any commit unless there is a branch, so if you want to go back and edit, you will need to either reset a branch to the commit you want to edit (real go back) or create a new branch at that commit
1 Like

Yes yes, you are both correct… how foolish of me. I forgot I have to specify a new branch / branch name. Thanks!

Still, I am curious about some of that local IDE behaviour. I will have to keep a better note of it as I go.

I was able to find a specific instance of this odd bevaviour now:

I have several similar forms, and I wanted to add the same code to their def form_show(self, **event_args): event, so I copied the code exactly from one to the next.
The code did not execute on the form that I copied it to.

I had to manually go to the visual editor, go to the Form Properties → Events → Show → and then click “Show Form”, which generated the event code for me in the editor.

Even though the generated code is identical to the code I copied, it is only after pressing the “show” button from the “Events” panel of the visual editor, and then copying in the rest of my code, did that code execute.

Similarly, I can also just press “show” from the Events panel, and the code I copied in remains, but now it executes properly.

That’s normal behavior. You have to both have the event handler function, and tell the component to use it. Copying the code provides the function, but clicking on the event in the properties pane tells the component to use it.

1 Like

How could it be done programmatically instead of using the visual editor?

You use add_event_handler on the component.

2 Likes