Closed israelroldan closed 1 year ago
I took a stab at it but it feels a bit of a chicken and egg situation as the plugin is doing the right thing (initializing defaultLanguages when the document is new) but it feels to be there should be a check of "has this document just been deleted?)
I wonder if this is more of a shortcoming of the studio (which stays on the just-deleted document URL) who is triggering the hooks on just-deleted documents.
Thanks for making this awesome plugin available! 🎉
We just found a bug that can be reproduced in this minimal test case: https://github.dev/israelroldan/sanity-i18nplugin-tc
Description of the issue
When an internationalized field is added to a document, documents of that type can't be fully deleted.
Steps to reproduce
Expected behaviour
The document is deleted
Actual result
The document is immediately recreated empty and can't be deleted
Additional information
The root cause is the code used by the plugin to add default languages. When a document is deleted the studio hooks are re-executed and the conditions present in
src/components/InternationalizedArray.tsx#108-119
are applicable so the call tohandleAddLanguages(defaultLanguages)
takes place, effectively adding default languages to the just deleted document, forcing its re-creation.Disabling
defaultLanguages
is a workaround at the moment.