You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(live-preview): client-side live preview failed to populate localized fields - #13794
The findByID endpoint, by default, expects the data for localized fields to be an object, values mapped to the locale. This is not the case for client-side live preview, as we send already-flattened data to the findByID endpoint.
For localized fields where the value is an object (richText/json/group), the afterRead hook handler would attempt to flatten the field value, even though it was already flattened.
Solution
The solution is to expose a flattenLocales arg to the findByID endpoint (default: true) and pass flattenLocales: false from the client-side live preview request handler.
To see the specific tasks where the Asana app for GitHub is being used, see below:
The reason will be displayed to describe this comment to others. Learn more.
The previous logic for shouldRunHookOnAllLocales was incorrect (and it unnecessarily ran for every single hook).
Specifically this part was incorrect (see red diff):
(locale === 'all' || !flattenLocales)
The locale === 'all' condition is correct, but logically there is no reason for it to check for the !flattenLocales attribute.
Instead, we want to know if the value is still in a a locale-value mapped state
=> this is not solely determined by the flattenLocales arg - just because we pass flattenLocales false does not mean the object is still in locale-value-mapped state (see live-preview)
=> check for shouldHoistLocalizedValue instead - if that is true, the object was definitely in locale-value-mapped state => it definitely no longer is in locale-value-mapped state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13756
The findByID endpoint, by default, expects the data for localized fields to be an object, values mapped to the locale. This is not the case for client-side live preview, as we send already-flattened data to the findByID endpoint.
For localized fields where the value is an object (richText/json/group), the afterRead hook handler would attempt to flatten the field value, even though it was already flattened.
Solution
The solution is to expose a
flattenLocalesarg to the findByID endpoint (default: true) and passflattenLocales: falsefrom the client-side live preview request handler.