Fix fields widget new field visibility (#21111)
Fixes https://github.com/twentyhq/twenty/issues/21043 ## Context Newly created fields were never added to FIELDS widgets, regardless of the "Set fields created in the future as visible" toggle. The widget's newFieldDefaultVisibility was null on widgets that never explicitly set it (it was never populated at creation), so the backend skipped them and no view field was created. ## Implementation Keep newFieldDefaultVisibility nullable with false (not visible) as the behavior when not provided. The FE now reflects that properly and shows "un-toggled" when it's null (iso with BE behavior). The fix also ensures the value is explicitly set to true wherever it should be: - Set newFieldDefaultVisibility: true at every FIELDS widget creation path (backend default record-page layout, frontend createDefaultFieldsWidget + useTemporaryFieldsConfiguration); - Added a 2-9 workspace upgrade command that backfills true onto existing standard FIELDS widgets where the value is null.
This commit is contained in:
+19
@@ -40,6 +40,25 @@ export const validateFieldsFlatPageLayoutWidgetForCreation = (
|
||||
return errors;
|
||||
}
|
||||
|
||||
const newFieldDefaultVisibility = (
|
||||
universalConfiguration as {
|
||||
configurationType: string;
|
||||
newFieldDefaultVisibility?: unknown;
|
||||
}
|
||||
).newFieldDefaultVisibility;
|
||||
|
||||
if (
|
||||
isDefined(newFieldDefaultVisibility) &&
|
||||
typeof newFieldDefaultVisibility !== 'boolean'
|
||||
) {
|
||||
errors.push({
|
||||
code: PageLayoutWidgetExceptionCode.INVALID_PAGE_LAYOUT_WIDGET_DATA,
|
||||
message: t`Invalid newFieldDefaultVisibility for fields widget "${widgetTitle}". Expected a boolean`,
|
||||
userFriendlyMessage: msg`Invalid newFieldDefaultVisibility for fields widget`,
|
||||
value: newFieldDefaultVisibility,
|
||||
});
|
||||
}
|
||||
|
||||
const viewUniversalIdentifier = (
|
||||
universalConfiguration as {
|
||||
configurationType: string;
|
||||
|
||||
+2
@@ -78,6 +78,7 @@ export const computeFlatDefaultRecordPageLayoutToCreate = ({
|
||||
? {
|
||||
configurationType: WidgetConfigurationType.FIELDS,
|
||||
viewId: recordPageFieldsView.id,
|
||||
newFieldDefaultVisibility: true,
|
||||
}
|
||||
: {
|
||||
configurationType:
|
||||
@@ -90,6 +91,7 @@ export const computeFlatDefaultRecordPageLayoutToCreate = ({
|
||||
? {
|
||||
configurationType: WidgetConfigurationType.FIELDS,
|
||||
viewUniversalIdentifier: recordPageFieldsView.universalIdentifier,
|
||||
newFieldDefaultVisibility: true,
|
||||
}
|
||||
: {
|
||||
configurationType:
|
||||
|
||||
Reference in New Issue
Block a user