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
6 of 8 tasks
TrySound opened this issue Jan 21, 2025 · 0 comments
Open
6 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.
  • 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.
  • 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.
  • 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
TrySound added a commit that referenced this issue Jan 24, 2025
Ref #4768

Here made a few changes to align data variables with css variables.

1. inherited variables are also shown in "Data Variables" section in
Settings
2. local and remote variables have blue and orange labels
3. local variables with the same name "mask" inherited variables in the
list
4. inherited variables can only be inspected

<img width="244" alt="image"
src="https://github.com/user-attachments/assets/bf4648e6-b5fc-48cb-a6c3-a6d5e8b234cd"
/>
TrySound added a commit that referenced this issue Jan 26, 2025
Ref #4768

Here improved copy paste experience between expressions.
All expressions while editing have are no longer encoded with ids.
For example `system.search.name` is the same.
Though invalid js characters are encoded with code point like this
`Collection Item.title` becomes `Collection$32$Item.title` when copy
into textual editor.

And this less obscure name can be copied between different lists with
the same variable name.
TrySound added a commit that referenced this issue Jan 27, 2025
Ref #4768

Here improved copy paste experience between expressions. All expressions
while editing have are no longer encoded with ids. For example
`system.search.name` is the same.
Though invalid js characters are encoded with code point like this
`Collection Item.title` becomes `Collection$32$Item.title` when copy
into textual editor.

And this less obscure name can be copied between different lists with
the same `Collection Item` name.
TrySound added a commit that referenced this issue Jan 27, 2025
Ref #4768 #4753

User can paste expression with not defined variable
and should get it saved in case of accidental closing popover.

Now such expressions can be executed in builder and will be compiled
with undefined instead of variables in published sites.

In the future we need to add global diagnostics to let users find such
places faster.

Also fixed a couple of ui issues
- react error about using button inside of button in data variables list
- react error about using unknown middlewareData prop from floating-ui
TrySound added a commit that referenced this issue Jan 27, 2025
Ref #4768
#4753

User can paste expression with not defined variable and should get it
saved in case of accidental closing popover.

Now such expressions can be executed in builder and will be compiled
with undefined instead of variables in published sites.

In the future we need to add global diagnostics to let users find such
places faster.

Also fixed a couple of ui issues
- react error about using button inside of button in data variables list
- react error about using unknown middlewareData prop from floating-ui

<img width="307" alt="Screenshot 2025-01-27 at 16 30 58"
src="https://github.com/user-attachments/assets/2ddc9ead-33a2-4438-b641-6943d7472f7e"
/>
TrySound added a commit that referenced this issue Jan 30, 2025
Ref #4768

Now user can write expressions with not existing variables
and create these variables later. They will automatically
traverse all expressions and bind to newly created variable
by name.

Additionally user will see suggestions with all unset variables
in subtree.
TrySound added a commit that referenced this issue Jan 31, 2025
Ref #4768

Now user can write expressions with not existing variables and create
these variables later. Builder will automatically traverse all
expressions and bind to newly created variable by name.

Additionally user will see suggestions with all unset variables in
subtree.

<img width="504" alt="Screenshot 2025-01-30 at 12 35 21"
src="https://github.com/user-attachments/assets/6d042f45-ca4a-49b9-9259-7be2a3c74bdd"
/>
TrySound added a commit that referenced this issue Feb 3, 2025
Ref #4768

Unset variables when copy and restore when paste.

Now you can copy instances with references to `system` variable
and it will be connected on another page as well when you paste.
TrySound added a commit that referenced this issue Feb 4, 2025
Ref #4768

Unset variables when copy and restore when paste.

Now you can copy instances with references to `system` variable and it
will be connected on another page as well when you paste.
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