State is not persisted when mobile block is not visible

Inside my screen, I have a container and a button. The button is used to toggle the visible property of the container. By default, the container is visible. Within this container is a block. This block contains 1 input widget.

- Screen

    - Button

    - Container

        - Block

            - Input


  1. I typed 'foo' in Input.
  2. I clicked on Button. Container is hidden.
  3. I clicked on Button again. Container is shown again but input does not have 'foo' anymore.

Is this behavior expected? Will hiding Container makes Block to go through its lifecycle again? Is changing the visibility of a widget considered as a screen navigation or transition?

Kaiming Thia wrote:

Inside my screen, I have a container and a button. The button is used to toggle the visible property of the container. By default, the container is visible. Within this container is a block. This block contains 1 input widget.

- Screen

    - Button

    - Container

        - Block

            - Input


  1. I typed 'foo' in Input.
  2. I clicked on Button. Container is hidden.
  3. I clicked on Button again. Container is shown again but input does not have 'foo' anymore.

Is this behavior expected? Will hiding Container makes Block to go through its lifecycle again? Is changing the visibility of a widget considered as a screen navigation or transition?

Hi Kaiming Thia,

Yes, Setting up the Visibility will re-generate the HTML again & thus I would recommend you to use the IF widget to hide components & try. 

Do correct me, If I am wrong!!!

Hope it helps you.

Thanks

Hi assif_tiger

I did as you recommended and enclosed Container within a If widget. However, the result is the same. Only Block's Input will not retain its value. I tried placing another Input directly in Screen and that Input will retain though. It seems this affects only inputs within a block. 

- Screen

    - Button

    - Container

        - Block

            - Input1

        - Input2

  1. I typed 'foo' in Input1.
  2. I typed 'bar' in Input2.
  3. I clicked on Button. IF widget is false, hiding Container.
  4. I clicked on Button again. IF widget is true, showing Container. 
  5. Input does not have 'foo' anymore.
  6. Input2 retains 'bar'.