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

extension.entry.fields[field].setValue(value, locale) updates entry, but UI doesn't update #166

Closed
cachrisman opened this issue May 21, 2018 · 3 comments

Comments

@cachrisman
Copy link
Member

I'm working on an extension and it makes a call

// field = 'title', locale = 'en-AU', and value = 'I am a title'
extension.entry.fields[field].setValue(value, locale)

and the entry is updated on the API, but the webapp UI doesn't update. Anything I can do to get the UI to update correctly?

@floelhoeffel
Copy link
Contributor

@cachrisman you mean in the actual UI Extension that sets the field value?

If you send a new value to the API the UI extension needs to take care of reflecting the change visually. The best practice is to listen for

https://github.com/contentful/ui-extensions-sdk/blob/master/docs/ui-extensions-sdk-frontend.md#extensionfieldonvaluechangedcb-function

That handler triggers for every value change the API is aware of.

@nerdess
Copy link

nerdess commented Jun 29, 2023

@floelhoeffel the docs seem to have moved, can you point to the new docs? I have the same issue but are struggeling to find the solution you have referenced.


edit: I think I found it. feels quite cubersome though:

const [value, setValue] = useState('');
someField.onValueChanged((newValue) => {
    if (newValue !== value) setValue(newValue);
});

@vctrivas
Copy link

Seeing an issue when expecting field.onValueChanged to be triggered when using a different locale than the fallback on setValue.

Here a simplified example:

With fallback en-US locale:

field.onValueChanged('en-US', () => {console.log('updated')}) // works as expected
field.setValue('some value', 'en-US')

With es as locale:

field.onValueChanged('es', () => {console.log('updated')}) // will not be triggered
field.setValue('some value', 'es')

You can see here when the locale is set to a different locale than the fallback the onValueChanged will not be triggered.

Any suggestions?

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

No branches or pull requests

5 participants