Open_form() doesn't end the existing form

For some reason this technique is 100% not working for me :frowning_face: :frowning_face: :frowning_face:

I want to be able to switch to a confirm form if I get a confirm token when the page loads. To test, I created Form1 and Form2.

Forms are:

class Form1(Form1Template):
  def __init__(self, **properties):
    # Set Form properties and Data Bindings.
    goto_confirm = True
    if goto_confirm:
      print("Opening form...")
      confirm_form = Form2()
      open_form(confirm_form)
      confirm_form.say_hi()
      print("Form2 is open...")
      return
    self.init_components(**properties)
    print("... and I'm still here!")

  def confirm_button_click(self, **event_args):
    print("Opening Form1...")
    confirm_form = Form2()
    open_form(confirm_form)
    confirm_form.say_hi()
    print("Form2 is open...")
    return

class Form2(Form2Template):
  def __init__(self, **properties):
    # Set Form properties and Data Bindings.
    self.init_components(**properties)
    print("Hello I'm initializing Form 2")
    
  def say_hi(self):
    print("HI FROM FORM2!")
    # Any code you write here will run when the form opens.

I would expect this to open Form2 as soon as Form1 loads. Output is this:

Opening Form1...
Hello I'm initializing Form 2
HI FROM FORM2!
Form2 is open...

However, Form1 is still on the screen!!! If I click the button, Form2 opens as expected … using the same code :woman_shrugging: (I even tried going through the event handler by raising a click and got the same results!!!)