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

Updating empty values #7

Open
Guiqft opened this issue Oct 14, 2022 · 6 comments · May be fixed by #8
Open

Updating empty values #7

Guiqft opened this issue Oct 14, 2022 · 6 comments · May be fixed by #8
Labels
bug Something isn't working cannot reproduce

Comments

@Guiqft
Copy link

Guiqft commented Oct 14, 2022

If you clear the input of the original field, the computed interface may throw a error because [].replace cannot exists, for example.
Or, if we clear a number field, the computed value may emit a "NaN" string, instead of null.

@Guiqft Guiqft linked a pull request Oct 14, 2022 that will close this issue
@duydvu
Copy link
Contributor

duydvu commented Oct 15, 2022

Can you give an example to reproduce this bug?

@duydvu duydvu added the bug Something isn't working label Oct 16, 2022
@Guiqft
Copy link
Author

Guiqft commented Oct 26, 2022

Here is a GIF showing the bug:
ezgif-5-e3eb47a73b

I think that the computed value must emit a null if the source value is null.

@Guiqft
Copy link
Author

Guiqft commented Oct 26, 2022

We also have this:
ezgif-1-5736797894
I put these logs on interface.vue:63. Seems that the other computed field emitted a 0, his expression is simple: {{ MULTIPLY(numero,2) }}.
I think we must check if the source value is null before parse the expression.

@Guiqft
Copy link
Author

Guiqft commented Oct 27, 2022

@duydvu to reproduce this, you can create these fields:

  • number (numeric)
  • numberx2 ({{ MULTIPLY(number, 2) }}
  • text (string)
  • text_slug ({{ SLUG(text) }}

When you edit the text field but leaves number empty and tries to save the item, the numberx2 calculation is triggered and returns 0 (because number(null) x 2 = 0. Then, Directus complains about you trying to get out from a item that has unsaved changes.

@duydvu
Copy link
Contributor

duydvu commented Oct 27, 2022

Nope, still can't see the bugs. Which Directus version are you using? Mine is 9.10.0

@Guiqft
Copy link
Author

Guiqft commented Aug 21, 2023

Hi @duydvu! Sorry for the long time.
I can still reproduces this on a empty instance of Directus 10.5.3.
In the most basic example:

  • Create a INT field my_number with simple input
  • Create a INT field my_number_x2 with the computed extension {{ MULTIPLY(my_number, 2) }}

When typing any number then erasing on the source input, the computed input gives me 0 as result, but I think it should be null.

If the source is a empty value, the computed should be empty too.
This is the same cause that makes the computed field starts with 0 on the video below ("Compute If Empty" is enabled).

Screen.Recording.2023-08-21.at.17.26.21.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cannot reproduce
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants