twenty
twenty copied to clipboard
View becomes blank after deleting select
Bug Description
View becomes blank once we delete the select field that is currently being used.
Steps to Reproduce:
- Create new Select field
- Create new View-Kanban (use Select field that created before)
- Delete Select field on Settings Page
- Back again to View Page (it shows blank)
Expected behavior
Delete corresponding view simultaneously once select field is deleted. Add confirmation window to inform user that several views will be removed.
To resolve the issue where the view becomes blank after deleting a select field, follow these steps:
-
Modify view deletion logic:
- Update the
useViews,useViewFilters, anduseViewSortshooks to handle the deletion of views when the associated select field is deleted. Ensure that these hooks check for the existence of the select field and remove the corresponding views if the field is deleted.
- Update the
-
Add confirmation window:
- Update the
ViewPickerCreateOrEditContentandViewPickerCreateOrEditContentEffectcomponents to include a confirmation window. This window should inform the user about the views that will be removed when the select field is deleted.
- Update the
Example code snippets:
useViews.js:
// Add logic to delete views associated with the deleted select field
useEffect(() => {
if (deletedSelectField) {
const updatedViews = views.filter(view => view.fieldId !== deletedSelectField.id);
setViews(updatedViews);
}
}, [deletedSelectField]);
ViewPickerCreateOrEditContent.js:
// Add confirmation window logic
const handleDeleteSelectField = (fieldId) => {
const affectedViews = views.filter(view => view.fieldId === fieldId);
if (affectedViews.length > 0) {
if (window.confirm(`Deleting this field will remove ${affectedViews.length} views. Do you want to proceed?`)) {
deleteSelectField(fieldId);
}
} else {
deleteSelectField(fieldId);
}
};
Ensure these changes are integrated into the respective files and tested for the described scenario.
References
@Weiko https://github.com/twentyhq/twenty/issues/6028 may be related to this one too if you have any inputs?
The mentioned issue will be the next impact if this is not addressed/fixed
After this object field deletion and navigate back to view again
@Bonapara is it ok to delete the view directly when deleting the field, or should we add a modal when deleting the field to warn that the view will be deleted ?
We can delete it directly, at least for now!
Here is the GitStart Ticket for this issue: https://clients.gitstart.com/twenty/5449/tickets/TWNTY-6027