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 Item has changes even without any modifications #11088

Closed
3 tasks done
joselcvarela opened this issue Jan 17, 2022 · 7 comments · Fixed by #11170
Closed
3 tasks done

New Item has changes even without any modifications #11088

joselcvarela opened this issue Jan 17, 2022 · 7 comments · Fixed by #11170
Assignees
Labels

Comments

@joselcvarela
Copy link
Member

joselcvarela commented Jan 17, 2022

Preflight Checklist

Describe the Bug

When I am trying to leave the New Item view without any changes the confirmation modal appears.
Also, when I click Discard Changes it shows the confirmation modal again and this process repeats and I am not able to quit this view.

To Reproduce

I am not sure why this started happened now, but this is easy reproducible:

  1. Create a collection
  2. Open the New Item view on this collection
  3. Try to leave. Confirm leave modal must appear.

Errors Shown

See this screenshot
Screenshot 2022-01-17 at 06 46 25

Those are the edits, but I didn't make any change 🤔
The nextval thing comes from the default value from PostgreSQL

What version of Directus are you using?

9.4.3 (e258f3d - main)

What version of Node.js are you using?

v16.13.0

What database are you using?

postgis/postgis:13-3.1-alpine

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying Directus?

running locally

@joselcvarela joselcvarela changed the title Item has changes even without any modifications New Item has changes even without any modifications Jan 17, 2022
@rijkvanzanten
Copy link
Member

I noticed you have a status field in there too. What other fields exist in this collection?

@joselcvarela
Copy link
Member Author

I just created a collection without any fields, only ID (automatically created), and have the same issue 😕

@felipe-santos
Copy link

Hi friends,
for me, fixed:

return Object.keys(defaults.value).length > 0 || hasEdits.value;

change to:
return Object.keys(edits.value).length > 0 || hasEdits.value;

changes "defaults.value" to "edits.value"

@joselcvarela
Copy link
Member Author

Hi friends, for me, fixed:

return Object.keys(defaults.value).length > 0 || hasEdits.value;

change to: return Object.keys(edits.value).length > 0 || hasEdits.value;

changes "defaults.value" to "edits.value"

Object.keys(edits.value).length > 0 and hasEdits.value are the same, so not necessary.
The thing is: default value comes from database vendor, in this case Postgresql.

Maybe we need to differentiate default values created by users and other default values, and only do the check for default values created by user: Object.keys(defaultsByUser.value).length > 0 🤔

@rijkvanzanten
Copy link
Member

Maybe we need to differentiate default values created by users and other default values

There's no way to differentiate between the two. They're stored and returned in the same location by the database 👍🏻

@joselcvarela
Copy link
Member Author

Maybe we could ignore defaults which doesn't match the type value, for example, in this case nextval... does not match uuid so we should ignore it.

@rijkvanzanten
Copy link
Member

Yeah! There's also an active discussion on the knex-schema-inspector around a way to split up generated default values (like nextval()) and "regular" static ones (knex/knex-schema-inspector#73) cc @Oreilles

@nickrum nickrum self-assigned this Jan 19, 2022
nickrum added a commit that referenced this issue Jan 19, 2022
We should only show a warning if the user actually made changes to the item.

Fixes #11088
rijkvanzanten pushed a commit that referenced this issue Jan 19, 2022
We should only show a warning if the user actually made changes to the item.

Fixes #11088
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants