contentful / field-editors

React components and extensions for building Contentful entry editor
https://contentful-field-editors.netlify.app/
MIT License
150 stars 118 forks source link

Multi-reference extension not syncing referenced entry changes #403

Open knupska opened 4 years ago

knupska commented 4 years ago

Background I'm attempting to create an enhanced multi-reference editor, styled and operating as per the default Contentful (Forma 36) functionality, but from which I can have entry fields be directly editable on the sortable card.

This is to cut down on the multiple steps it currently takes a content author to open a referenced entry, check a field value, change the field value, publish and then return.

By leveraging the renderCustomCard property on the MultipleEntryReferenceEditor to return a reimplemented WrappedEntryCard and having that import a custom EntryCard based on the source, I have almost gotten this to work.

Unfortunately, changes that I make to the referenced entries using sdk.space.updateEntry are not syncing back into the MultipleEntryReferenceEditor.

Issue It appears that field extensions are not provided access to sdk.space.onEntityChanged, so the EntityStore used by the ReferenceEditor does not observe changes made to the referenced entries.

The default Entry links list appearance provided by Contentful does not experience this.

I have not been able to find a viable workaround to having the referenced entries update after either my own or external changes.

Replication The lack of syncing changes from referenced entries into the multi-reference extension can be seen in the extensions/multiple-references-extension example provided in this repository.

The status and values shown on the card in the first window will quickly become out of sync.

multi-reference-no-sync
knupska commented 3 years ago

As there has been no activity on this issue for several weeks, I will attempt to clarify.

When the MultipleEntryReferenceEditor is used as an extension, any changes made to the referenced entries are not kept in sync regardless of how those changes are made:

This is not caused by our extension, code or edits. It can be seen directly in the multiple-references-extension example provided by Contentful.

Under the most basic usage where an entry is edited in the same tab, the changes sync once the edit pane is closed because the EntityStore has a fallback to listen to the slide in navigation. This isn't useful when the changes could be originating from any number of places as outlined above.

This issue is a roadblock for the following extension created to address client complaints that the default Contentful UI isn't streamlined enough.

on-card-stock
djagya commented 3 years ago

Hi @knupska, thanks a lot for the detailed report, I appreciate the time you spent on investigation. And sorry for the delayed answer.

You're right, sdk.space.onEntityChanged is only accessible within the web app and can not be accessed from the public widget SDK. As you correctly said, exposing this method would allow reference cards to be updated whenever an entry is changed elsewhere.

I will ask the team managing https://github.com/contentful/ui-extensions-sdk if we can expose it.

djagya commented 3 years ago

There's nothing stopping us from adding it to the public SDK, but first we want to wait for https://github.com/contentful/ui-extensions-sdk/pull/345 to be finished. I added a ticket to our backlog and will keep you updated.

knupska commented 3 years ago

Thanks for chasing it up @djagya.

Apologies for reporting it here too, I hadn't noticed those methods were actually being exposed by the ui-extensions-sdk package.

github-actions[bot] commented 2 years ago

Marking issue as stale since there was no activity for 30 days

knupska commented 1 year ago

It's been some time (almost 3 years), can anyone at Contentful advise if this was ever added to the public widget SDK, or if it has otherwise changed in a way where it is now possible to achieve via an extension?

github-actions[bot] commented 1 year ago

Marking issue as stale since there was no activity for 30 days

th1nkgr33n commented 5 months ago

We encounter this behaviour in the latest app framework as well. Using the renderCustomCard-prop will lead to not updated List if you add or edited an entry.

github-actions[bot] commented 4 months ago

Marking issue as stale since there was no activity for 30 days