Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New data variables behavior #4768

Open
1 of 8 tasks
TrySound opened this issue Jan 21, 2025 · 0 comments
Open
1 of 8 tasks

New data variables behavior #4768

TrySound opened this issue Jan 21, 2025 · 0 comments
Assignees

Comments

@TrySound
Copy link
Member

TrySound commented Jan 21, 2025

Here's a few updates I'm gonna do to align data variables behavior with css variables. This change is essential for global variables and component parameters support.

  • Variables with the same name are forbidden within the same instance.

    • Allowing multiple variables with the same name on the same instance can confuse users and lead to unexpected behavior.
  • A variable with the same name on a child instance will mask the variable on the parent instance.

    • This is similar to CSS variables; a variable defined on a child will override the parent variable with the same name within the child’s scope. The parent variable becomes inaccessible in this scenario.
  • Removing a variable on a child instance will update all expressions:

    • If a parent instance has a variable with the same name, expressions using the removed child variable will switch to reference the parent variable.
    • If no parent variable exists, the expressions will switch to "unset" variable.
  • An "unset" variable is created when an actual variable is removed.

    • Retaining the variable name ensures that expressions referencing the removed variable do not break. Expressions internally store references as obscure IDs.
  • Adding a new variable with the same name as an "unset" variable will update expressions:

    • Any expressions referencing the "unset" variable will automatically begin referencing the newly created variable.
  • show inherited variables from ancestors in "Data Variables" section

  • use orange and blue labels for variable names to distinct inherited and instance variables

  • show only "inspect" option in inherited variable menu

@TrySound TrySound self-assigned this Jan 21, 2025
TrySound added a commit that referenced this issue Jan 22, 2025
Ref #4768

We don't want to allow data variables on one instance with the same
name. Though we will allow child variables to mask parent ones in
another PR.
TrySound added a commit that referenced this issue Jan 22, 2025
Ref #4768

We don't want to allow data variables on one instance with the same
name. Though we will allow child variables to mask parent ones in
another PR.


To test:
- create variable var1 on box
- try to create another variable with var1
- create variable var2
- try to rename it to var1
- create variable on body with var1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant