[Feature-16939]Perspective properties, "Add Before/After" from right-click menu does not properly update bindings

Running Ignition 8.0.14, I have a perspective view with a horizontal menu component. I have several menu items that each have bindings on the label and target. When I right click a menu item in the properties tree and hit “Add Before”, the index of the property bindings do not correctly update.

Steps to reproduce:

  • Create a horizontal menu component in a view
  • Add three menu items, bind their labels out via expression bindings to “0”, “1”, and “2”
  • Right click menu item “1” and hit “Add After.”
  • See how the bindings are all messed up.

You’re going to see this behavior on any component which has an array value into which you place bindings. It stems from how the bindings are stored, which is by the property path:

{
        "meta": {
          "name": "HorizontalMenu"
        },
        "position": {
          "height": 46,
          "width": 600,
          "x": 179,
          "y": 20
        },
        "propConfig": {
          "props.items[0].label": {
            "binding": {
              "config": {
                "expression": "\"0\""
              },
              "type": "expr"
            }
          }...

So when you introduce a new entry into the items array, any binding for an index AFTER the index at which you’ve added the entry will still be attached to the same index as before, which is now “wrong”. There’s not anything we can do about this. It’s not a bug per se because it’s behaving exactly as we’d expect it to. It could understandably be considered an undesirable behavior, but from a project development point-of-view, bindings should be the last changes to a View - adding entries or components after bindings are applied can lead to undesirable behaviors.

You guys are the experts, but I would love to see this "undesirable behavior" changed. Presumably, the function that executes when I click the "add before/add after" button could adjust the indices of the those bindings accordingly?

Do we see the same functionality with deleting items in an array that have bindings? That could be frustrating for clients who frequently buy/sell assets and want to add and remove pages from their navigation bars frequently.

It’s not “safe” to modify bindings when items are inserted OR removed from an array. The items could be added to or removed at runtime and there is no way to properly account for that.

Consider a menu where you’re dynamically adding or removing users by name at runtime… If you have any bindings in there, they’d be attached to incorrect users as the items array is generated based off of your changes.

I’ll ask around, but I think this is one of those instances where it’s best for us to keep our hands off. Array elements in general are not a great place to place bindings. You should consider binding the items array itself to some sort of value, and then generating the array with the changes you need to be in place, instead of applying static bindings.

1 Like

That being said, Development believes differently. Since this would be Designer-only, it is believed we can improve this. I’ve opened an internal ticket to track the feature.

1 Like

Way to go, Development!

I have custom property “SubMenuDataset” on a view. For some reason, I have added one element in the that property i.e. 3rd. After that I found the property binding remain at same position of the element. See screenshot.
I have added 3rd element in the property. And Property binding remain at element 5 > Submenutitle. Actually it should shift to element 6 as I have added one element in it. The other variables shifted correctly to element 6. i.e. “MenuIndex” = 3, SubMenuIndex = 3

Another, issue after added 3rd element, some variables are missing from elements like “Submenutitle” variable. Please see element 6 and 7 there is no “Submenutitle” variable. But if you see the property binding is showing in blue color right of the element 6 and 7.

Then I tried to manually insert new variable with same name “Submenutitle”. Some time it is showing error overlay on name as same variable is present in the element after 2-3 attempts I can able to add the “Submenutitle” variable and see the binding.

When I run the perspective that time found in my menu there are multiple tabs created with same name i.e. value, value1 etc.

Then I opened the custom property and found that there are multiple variables created under element, where I tried to create "“Submenutitle” variable.

image