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

Unable to edit or create items for collections with translations #12005

Closed
3 tasks done
HitomiTenshi opened this issue Mar 7, 2022 · 8 comments
Closed
3 tasks done

Unable to edit or create items for collections with translations #12005

HitomiTenshi opened this issue Mar 7, 2022 · 8 comments
Labels

Comments

@HitomiTenshi
Copy link
Contributor

Preflight Checklist

Describe the Bug

Since v9.5.2 (also in v9.6.0) you cannot edit or create new items for collections that have translations. I tested the issue with WYSIWYG fields, it might also affect other fields.

What happens is that directus preemptively makes a change for translations when entering the item page / creating a new item. This causes the save button the be active immediately upon entering an existing item. The pre-filled change for translations does not have the language ID in the object which causes the PATCH API to return status code 400 (bad request).

chrome_2022-03-07_12-25-43.mp4

When trying to create a new item, the WYSIWYG field says that it is required (it is, but I wrote something in it, so it should save).

chrome_2022-03-07_12-44-21.mp4

The issue happens because both the collection field and the translation field have the same name! That's pretty twisted... When I initially tested it I couldn't reproduce it until I named the WYSIWYG fields in both collections the same.

To Reproduce

  1. Create a new collection
  2. Add a WYSIWYG field and call it "text", make sure it's NOT NULL
  3. Add a translations field
  4. In the new translations collection, add a WYSIWYG field and call it "text", make sure it's NULL

Now try to create an item. Prepare to cry 😢

When there are existing items you will get the PATCH issue I showed in the first video.

The reasoning behind the main collection field being NOT NULL and the translations field allowing NULL is that the translated fields are optional. We have multiple translatable fields that do not have to be filled out and everything used to work in v9.5.1. We have downgraded to that version now.

Errors Shown

PATCH API shows status code 400.

During creation of new items the WYSIWYG fields complain about being required even though they have a value.

What version of Directus are you using?

9.6.0

What version of Node.js are you using?

16.14.0

What database are you using?

MariaDB 10.3.34

What browser are you using?

Chrome Latest

What operating system are you using?

Windows 10

How are you deploying Directus?

Ubuntu Server 20.04, npm installation with a systemd service running it

@iksent
Copy link
Contributor

iksent commented Mar 10, 2022

I have a similar problem. Can't understand, should I open a new issue or not.

  1. I have Articles model and Translations for them.
  2. Translations have Wysiwyg field.
  • If I go to Article editing and try to edit Wysiwyg inside translations: it ignores changes and I can't save the Article.
2022-03-10.14.37.06.mov
  • But if I go to Article Translations and try to edit Wysiwyg there, then it works:
2022-03-10.14.37.51.mov

I've tried both 9.5.2 and 9.6.0 :(

@rijkvanzanten
Copy link
Member

I have a similar problem. Can't understand, should I open a new issue or not.

  1. I have Articles model and Translations for them.
  2. Translations have Wysiwyg field.
  • If I go to Article editing and try to edit Wysiwyg inside translations: it ignores changes and I can't save the Article.

2022-03-10.14.37.06.mov

  • But if I go to Article Translations and try to edit Wysiwyg there, then it works:

2022-03-10.14.37.51.mov

I've tried both 9.5.2 and 9.6.0 :(

Very odd! I'm wondering if that's a bug in the translations interface (which would make it related to this), or a bug in the wysiwyg 🤔

@onordgren
Copy link

I have a similar problem. Can't understand, should I open a new issue or not.

  1. I have Articles model and Translations for them.
  2. Translations have Wysiwyg field.
  • If I go to Article editing and try to edit Wysiwyg inside translations: it ignores changes and I can't save the Article.

2022-03-10.14.37.06.mov

  • But if I go to Article Translations and try to edit Wysiwyg there, then it works:

2022-03-10.14.37.51.mov
I've tried both 9.5.2 and 9.6.0 :(

Very odd! I'm wondering if that's a bug in the translations interface (which would make it related to this), or a bug in the wysiwyg 🤔

I also have this issue and I tried replacing the wysiwyg with a markdown editor on the main objects and then it works fine.

@onordgren
Copy link

@rijkvanzanten I did some more testing on this one and got the following "results":

Baseline: collection faq with the wysiwyg field called answer

I add a translations interface to faq with a child wysiwyg field called answer

  • When I try to create a new faq the answer wysiwyg will not set the value of the field rendering the field invalid if it's required or empty if not
  • If I set the value with set raw value it works
  • If I change the name of the field to something else it will work, i.e. not colliding with the field on the translations relation
  • If I use a markdown field instead of wysiwyg it works

So to me it feels like something is happening client side in the wysiwyg when it tries to set the actual value of the field. Maybe there's a conflict with the field with the same name on the translations relation?

@onordgren
Copy link

@rijkvanzanten I did some more testing on this one and got the following "results":

Baseline: collection faq with the wysiwyg field called answer

I add a translations interface to faq with a child wysiwyg field called answer

  • When I try to create a new faq the answer wysiwyg will not set the value of the field rendering the field invalid if it's required or empty if not
  • If I set the value with set raw value it works
  • If I change the name of the field to something else it will work, i.e. not colliding with the field on the translations relation
  • If I use a markdown field instead of wysiwyg it works

So to me it feels like something is happening client side in the wysiwyg when it tries to set the actual value of the field. Maybe there's a conflict with the field with the same name on the translations relation?

Maybe related to b3f7bd9

@maltejur
Copy link
Contributor

maltejur commented Mar 20, 2022

Maybe related to b3f7bd9

Reverting that commit does indeed seem to fix the issue https://github.com/maltejur/directus/tree/revert_b3f7bd9
Edit: I am dumb, even without that commit reverted everything works just fine for me.

I think this whole issue was fixed in #12216. If I revert that merge commit the issue occurs again.

@onordgren
Copy link

This has been resolved for me with 9.7.0!

@HitomiTenshi
Copy link
Contributor Author

I can confirm what @onordgren and @maltejur have already said. The issue has been fixed in 9.7.0. It seems by PR #12216 with the last change "Fix incorrect DOM selection of WYSIWYG interface for fields having the same name".

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

No branches or pull requests

6 participants