MainUI variable not refreshed across several widgets?

In MainUI pages, I am trying to set attributes in some widgets based on variable actions performed on other widgets but it seems the expression using the variables is not refreshed.

For example in this simple test, I can’t get the second label to update upon action on the first:

config:
  label: Tests vars
  sidebar: true
blocks:
  - component: oh-block
    config: {}
    slots:
      default:
        - component: oh-grid-row
          config: {}
          slots:
            default:
              - component: oh-grid-col
                config: {}
                slots:
                  default:
                    - component: oh-label-card
                      config:
                        action: variable
                        actionVariable: testvar
                        actionVariableValue: MyValue
                        label: Set testvar to MyValue
        - component: oh-grid-row
          config: {}
          slots:
            default:
              - component: oh-grid-col
                config: {}
                slots:
                  default:
                    - component: oh-label-card
                      config:
                        label: '="Variable = "+ ((vars.testvar) ? vars.testvar : "N/A")'
masonry: null
grid: []
canvas: []

When looking at the Keypad example, it looks like this is exacly what is done. Is it a limitation where a variable can only be used within the same (custom) widgets but not across several widgets in a page?

I can’t say that for sure, but that is how I would expect it to work. There isn’t a mechanism I know of to have widgets interact with each other in that way. Instead of a variable you might be able to use an Item.

I haven’t experimented with it much myself yet, but try defining the variables in the config of the page that the widgets are on, that might give them a broader context:

Thanks for the idea. It worked when defining variables in the page config. I had come across that thread but I thought that using this configuration would only provide default value to variables.

Thanks for the help but I’d rather not use items for this purpose as I believe UI behaviour specific to one UI type (MainUI feel in this case) should be somehow independent from items and the interaction performance would probably not be as good. Furthermore it affect all UI instances with is not what I am looking for.

The ultimate goal is to select different layers in a canvas page without having to duplicated the page, hence resorting to variables.

This seems related