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

fix(frontend/bulk-edit): unsaved changes warning for task when task not changed #567

Conversation

c0rydoras
Copy link
Collaborator

this was caused by

{{#if
  (and
    f.model.change.task
    (not (eq f.model.change.task.id model.task.id))
  )
}}
  <ChangedWarning />
{{/if}}

when the changeset is modified f.model.change.task will be set to an empty object, this satisfies the first condition as objects are always truthy:

{{#if
  (and
    {}
    (not (eq f.model.change.task.id model.task.id))
  )
}}
  <ChangedWarning />
{{/if}}

when we now look at the values of f.model.change.task.id and model.task.id, we can see that: f.model.change.task.id -> undefined
model.task.id -> null

null and undefined aren't the same, therefore: (not (eq f.model.change.task.id model.task.id)) -> (not (eq undefined null)) -> (not (false)) -> true

because of that, modifying another value of the changeset resulted in:

{{#if
  (and
    {}
    true
  )
}}
  <ChangedWarning />
{{/if}}

@c0rydoras c0rydoras requested a review from a team as a code owner January 7, 2025 14:51
@c0rydoras c0rydoras enabled auto-merge (squash) January 7, 2025 17:50
…ot changed

this was caused by

```glimmer
{{#if
  (and
    f.model.change.task
    (not (eq f.model.change.task.id model.task.id))
  )
}}
  <ChangedWarning />
{{/if}}
```

when the changeset is modified `f.model.change.task` will be set to an empty object, this satisfies the first condition as objects are always truthy:

```glimmer
{{#if
  (and
    {}
    (not (eq f.model.change.task.id model.task.id))
  )
}}
  <ChangedWarning />
{{/if}}
```

when we now look at the values of `f.model.change.task.id` and `model.task.id`, we can see that:
`f.model.change.task.id` -> `undefined`
`model.task.id` -> `null`

`null` and `undefined` aren't the same, therefore:
`(not (eq f.model.change.task.id model.task.id))` -> `(not (eq undefined null))` -> `(not (false))` -> `true`

because of that, modifying another value of the changeset resulted in:

```glimmer
{{#if
  (and
    {}
    true
  )
}}
  <ChangedWarning />
{{/if}}
```
@c0rydoras c0rydoras force-pushed the fix/frontend/bulk-edit/unsaved-changes-task branch from 64abf8b to 19fcfe0 Compare January 8, 2025 10:23
Copy link
Member

@trowik trowik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@c0rydoras c0rydoras merged commit 3b3629a into adfinis:main Jan 8, 2025
10 checks passed
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

Successfully merging this pull request may close these issues.

[BUG]: "unsaved changes" in "Task" field when checking "Verified" seems wrong; is this a bug?
3 participants